# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
710120 | 2023-03-15T04:53:57 Z | Tyx2019 | Money (IZhO17_money) | C++17 | 0 ms | 0 KB |
#include <bits/stdc++.h> #define int long long using namespace std; main(){ int N; cin >> N; int A[N]; for(int i=0;i<N;i++) cin >> A[i]; multiset<int> S; queue<int> Q; int prev=-1; int cnt=1; int lessthan=INT_MAX; for(int i=0;i<N;i++){ if(prev==-1){ prev=A[i]; auto k=S.upper_bound(A[i]); if(k!=S.end()){ lessthan=*k; } Q.push(A[i]); continue; } if(A[i]>=A[i-1]&&A[i]<=lessthan){ Q.push(A[i]); continue; } prev=-1; cnt++; i--; while(!Q.empty()){ S.insert(Q.front()); Q.pop(); } leq=INT_MAX; } cout << cnt; }