get TLE

Revision en2, by Elkhateb, 2022-08-12 12:53:28

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

} ~~~~~

Tags help me

History

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