get TLE

Revision en1, by Abdelkareemkobo, 2022-08-12 12:52:58

[problem:https://codeforces.com/group/j67LErd7ji/contest/389254/problem/F][contest:https://codeforces.com/group/j67LErd7ji/contest/389254] I tried hard with this problem this is my solution but it gets TLE any helpful tips? ~~~~~ int main() { int t; cin>>t; while(t--){ ll n,q; cin>>n>>q; vectorarr(100000,0),arr2(100000,0); arr2[0] = 0; for(ll i=1;i<=n;i++) { ll lol; cin >> lol; if((lol)%2==0){

if(log2l(lol)==ll(log2(1.0L*lol)))
arr[i] = log2(lol);
else{
arr[i] =  ceil(log2((1.0L*lol)));
}
}else{
lol--;
if(log2l(lol)==ll(log2(1.0L*lol)))
arr[i] = log2(lol)+1;
else{
arr[i] =  ceil(log2(1.0L*lol))+1;
}
}
arr2[i]+=arr2[i-1]+arr[i];

// cout<<arr[i]<<" "; } // cout<<el; // for(int i=1;i<=n;i++){ // arr2[i] = arr2[i-1] + arr[i]; // } while(q--){ int l,r; cin>>l>>r; cout<<arr2[r] — arr2[l-1]<<'\n'; } }

return 0;//Q.E.D ^_^

} ~~~~~

#### History

Revisions

Rev. Lang. By When Δ Comment
en3 Abdelkareemkobo 2022-08-12 12:55:30 85
en2 Abdelkareemkobo 2022-08-12 12:53:28 7 Tiny change: '?\n~~~~~\nint main' -> '?\n~~~~~\n\n\n\nint main'
en1 Abdelkareemkobo 2022-08-12 12:52:58 1333 Initial revision (published)