Submission #167352

#TimeUsernameProblemLanguageResultExecution timeMemory
167352muhammad_hokimiyonMoney (IZhO17_money)C++14
100 / 100
1434 ms58220 KiB
#include <bits/stdc++.h> #pragma GCC optimize("Ofast") #define fi first #define se second #define ll long long using namespace std; const int N = 1e6 + 7; const int mod = 1e9 + 7; void solve() { int n; int ans = 0; set < int > s; cin >> n; vector < int > a(n + 1); for( int i = 1; i <= n; i++ ){ cin >> a[i]; } for( int i = 1 , j = 1; i <= n; i++ ){ if( a[i - 1] > a[i] ){ ans++; for( ; j < i; j++ ){ s.insert(a[j]); } } else{ auto it = s.upper_bound(a[j]); if( it != s.end() && *it < a[i] ){ ans++; for( ; j < i; j++ ){ s.insert(a[j]); } } } } cout << ans + 1; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); //freopen( "input.txt" , "r" , stdin ); //freopen( "output.txt" , "w" , stdout ); int t = 1;//cin >> t; while( t-- ){ solve(); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...