Submission #1023503

#TimeUsernameProblemLanguageResultExecution timeMemory
1023503hasan2006Money (IZhO17_money)C++17
100 / 100
126 ms22872 KiB
#include <bits/stdc++.h> using namespace std; #define TL ios::sync_with_stdio(0),cin.tie(0),cout.tie(0); #define rall(s) s.rbegin(),s.rend() #define all(s) s.begin(),s.end() #define pb push_back #define se second #define fi first #define ll long long #define ld long double #define YES cout<<"YES\n" #define Yes cout<<"Yes\n" #define yes cout<<"yes\n" #define NO cout<<"NO\n" #define No cout<<"No\n" #define no cout<<"no\n" const int N = 1e6 + 9 , mod = 1e9 + 7; ll d[N] , dp[N] , a[N] , b[N] , c[N]; void add(int x){ while(x <= 1000000){ dp[x]++; x += (x & -x); } } ll get(int x ){ ll ans = 0; while(x > 0){ ans += dp[x]; x -= (x & -x); } return ans; } void solve() { ll n , q , i , j ,l ,r , x , y , s = 0 , f , k , m , mn = 1e18, mx = 0 ; cin>>n; for(i = 1; i <= n; i++){ cin>>a[i]; } l = 1; while(l < n){ r = l + 1; while(r <= n){ if(a[r] < a[r - 1] || get(a[r] - 1) - get(a[l]) > 0){ s ++ ; break;} r++; } for(i = l; i < r; i++) add(a[i]); l = r; } cout<<s + 1<<"\n"; } int main(){ TL; /* #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif*/ int t = 1; // cin>>t; while(t--) { solve(); } } // Author : حسن

Compilation message (stderr)

money.cpp: In function 'void solve()':
money.cpp:41:12: warning: unused variable 'q' [-Wunused-variable]
   41 |     ll n , q , i , j ,l ,r , x , y , s = 0 , f , k , m , mn = 1e18, mx = 0 ;
      |            ^
money.cpp:41:20: warning: unused variable 'j' [-Wunused-variable]
   41 |     ll n , q , i , j ,l ,r , x , y , s = 0 , f , k , m , mn = 1e18, mx = 0 ;
      |                    ^
money.cpp:41:30: warning: unused variable 'x' [-Wunused-variable]
   41 |     ll n , q , i , j ,l ,r , x , y , s = 0 , f , k , m , mn = 1e18, mx = 0 ;
      |                              ^
money.cpp:41:34: warning: unused variable 'y' [-Wunused-variable]
   41 |     ll n , q , i , j ,l ,r , x , y , s = 0 , f , k , m , mn = 1e18, mx = 0 ;
      |                                  ^
money.cpp:41:46: warning: unused variable 'f' [-Wunused-variable]
   41 |     ll n , q , i , j ,l ,r , x , y , s = 0 , f , k , m , mn = 1e18, mx = 0 ;
      |                                              ^
money.cpp:41:50: warning: unused variable 'k' [-Wunused-variable]
   41 |     ll n , q , i , j ,l ,r , x , y , s = 0 , f , k , m , mn = 1e18, mx = 0 ;
      |                                                  ^
money.cpp:41:54: warning: unused variable 'm' [-Wunused-variable]
   41 |     ll n , q , i , j ,l ,r , x , y , s = 0 , f , k , m , mn = 1e18, mx = 0 ;
      |                                                      ^
money.cpp:41:58: warning: unused variable 'mn' [-Wunused-variable]
   41 |     ll n , q , i , j ,l ,r , x , y , s = 0 , f , k , m , mn = 1e18, mx = 0 ;
      |                                                          ^~
money.cpp:41:69: warning: unused variable 'mx' [-Wunused-variable]
   41 |     ll n , q , i , j ,l ,r , x , y , s = 0 , f , k , m , mn = 1e18, mx = 0 ;
      |                                                                     ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...