Submission #173527

#TimeUsernameProblemLanguageResultExecution timeMemory
173527AllMightMoney (IZhO17_money)C++14
0 / 100
2 ms376 KiB
#include <iostream> #include <algorithm> #include <vector> using namespace std; const int N = 1000006; int n; int a[N]; bool color[N]; int main() { ios_base::sync_with_stdio(false); cin >> n; for (int i = 0; i < n; i++) cin >> a[i]; int ans = 1; bool f = false; for (int i = n - 1; i > 0; i--) { color[a[i]] = true; if (a[i] == a[i - 1] + 1) continue; if (a[i - 1] > a[i]) { ans++; f = false; continue; } for (int j = a[i - 1] + 1; j <= a[i]; j++) { if (j == a[i]) { if (f) ans++; f = true; break; } if (!color[j]) { ans++; f = false; break; } } } cout << ans << endl; 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...