Submission #853291

#TimeUsernameProblemLanguageResultExecution timeMemory
853291NeroZeinMoney (IZhO17_money)C++17
0 / 100
1 ms2396 KiB
#include "bits/stdc++.h" using namespace std; #ifdef Nero #include "Deb.h" #else #define deb(...) #endif const int N = 1e6 + 6; int a[N]; int seg[N * 2]; int tt[N]; void upd(int i, int val) { tt[i] = val; } signed main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; for (int i = 0; i < n; ++i) { cin >> a[i]; } int ans = 1; vector<int> v; for (int i = 0; i < n; ++i) { if (v.empty()) { v.push_back(a[i]); upd(a[i], a[i]); } else { if (v.back() > a[i]) { ans++; v.clear(); v.push_back(a[i]); upd(a[i], a[i]); } else { if (tt[v[0]] > a[i]) { ans++; v.clear(); v.push_back(a[i]); upd(a[i], a[i]); } else { v.push_back(a[i]); upd(v[0], a[i]); } } } } cout << ans << '\n'; return 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...