jayati

Ques 1

Sep 1st, 2022 (edited)
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. #define ll long long int
  3. using namespace std;
  4.  
  5. int main() {
  6. // your code goes here
  7. ll t;
  8. cin>>t;
  9. while(t--)
  10. {
  11. ll n;
  12. cin>>n;
  13. ll count;
  14. while(n--)
  15. {
  16. ll s;
  17. cin>>s;
  18. ll a[s];
  19. count=0;
  20. for(ll i=0;i<s;i++)
  21. {
  22. cin>>a[i];
  23. }
  24. for(ll i=0;i<s-1;i++)
  25. {
  26. if(a[i+1]<a[i])
  27. {
  28. count++;
  29. }
  30. }
  31. count+=1;
  32.  
  33. }
  34. ll ans;
  35. if(count%2==0)
  36. {
  37. ans = (count+1)*(log2(count));
  38. cout<<ans<<endl;
  39. }
  40. else
  41. {
  42. ans = (count+1)*(log2(count));
  43. cout<<ans+1<<endl;
  44. }
  45.  
  46. }
  47. return 0;
  48. }
Advertisement
Add Comment
Please, Sign In to add comment