Abdelkareemkobo's blog

By Abdelkareemkobo, history, 2 months ago, In English

[problem:https://codeforces.com/group/j67LErd7ji/contest/389254/problem/F][contest:https://codeforces.com/group/j67LErd7ji/contest/389254] my submission linK:https://codeforces.com/group/j67LErd7ji/contest/389254/problem/F 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 ^_^

} ~~~~~

 
 
 
 
  • Vote: I like it
  • +11
  • Vote: I do not like it

»
2 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Auto comment: topic has been updated by Abdelkareemkobo (previous revision, new revision, compare).