get TLE

Правка en3, от Elkhateb, 2022-08-12 12:55:30

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

} ~~~~~

Теги help me

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en3 Английский Elkhateb 2022-08-12 12:55:30 85
en2 Английский Elkhateb 2022-08-12 12:53:28 7 Tiny change: '?\n~~~~~\nint main' -> '?\n~~~~~\n\n\n\nint main'
en1 Английский Elkhateb 2022-08-12 12:52:58 1333 Initial revision (published)