Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- #define ll long long int
- using namespace std;
- int main() {
- // your code goes here
- ll t;
- cin>>t;
- while(t--)
- {
- ll n;
- cin>>n;
- ll count;
- while(n--)
- {
- ll s;
- cin>>s;
- ll a[s];
- count=0;
- for(ll i=0;i<s;i++)
- {
- cin>>a[i];
- }
- for(ll i=0;i<s-1;i++)
- {
- if(a[i+1]<a[i])
- {
- count++;
- }
- }
- count+=1;
- }
- ll ans;
- if(count%2==0)
- {
- ans = (count+1)*(log2(count));
- cout<<ans<<endl;
- }
- else
- {
- ans = (count+1)*(log2(count));
- cout<<ans+1<<endl;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment