Submission #914779

#TimeUsernameProblemLanguageResultExecution timeMemory
914779mariamp1Money (IZhO17_money)C++14
0 / 100
1 ms348 KiB
# include <bits/stdc++.h> using namespace std; #define f first #define s second #define pii pair <int, int> #define pb push_back const int N = 3e5 + 5; int n, q, mn, r, mx; int main() { cin>>n; int a[n+1]; set<int> s; for(int i = 1; i <= n; i++){ cin >> a[i]; } int ans = 0; for(int i = 1; i <= n; i++){ mn = a[i]; ans++; for (int j = i; j <= n; j++){ if(a[j+1] < a[j]) { r = j; break; } mx = a[j + 1]; auto it = s.lower_bound(mn); if (it != s.end() && *it < mx) { r = j; break; } } for(int j = i; j <= r; j++){ s.insert(a[j]); } i = r; } cout << ans << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...