# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
38239 | 2018-01-03T05:37:34 Z | Just_Solve_The_Problem | Money (IZhO17_money) | C++11 | 0 ms | 9832 KB |
#include <bits/stdc++.h> using namespace std; #define pii pair < int, int > #define fr first #define sc second #define pb push_back #define ok puts("ok"); const int N = (int)1e6 + 7; pii a[N]; stack < int > st; int ans; main () { int n; scanf ("%d", &n); ans = n; for (int i = 1; i <= n; i++) { scanf ("%d", &a[i].fr); a[i].sc = i; } sort(a + 1, a + n + 1); for (int i = 1; i <= n; i++) { if (a[i].sc == a[i + 1].sc - 1) { ans--; continue; } int last = a[i].sc; bool fl = 0; if (st.size() > 1) { int cur = st.top(); st.pop(); if (st.top() + 1 == a[i].sc) { ans--; st.pop(); } else { st.push(cur); } } while (!st.empty() && last - 1 == st.top()) { last = st.top(); ans--; // ok fl = 1; st.pop(); } if (!fl) st.push(a[i].sc); } cout << ans; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 9832 KB | Output is correct |
2 | Correct | 0 ms | 9832 KB | Output is correct |
3 | Correct | 0 ms | 9832 KB | Output is correct |
4 | Incorrect | 0 ms | 9832 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 9832 KB | Output is correct |
2 | Correct | 0 ms | 9832 KB | Output is correct |
3 | Correct | 0 ms | 9832 KB | Output is correct |
4 | Incorrect | 0 ms | 9832 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 9832 KB | Output is correct |
2 | Correct | 0 ms | 9832 KB | Output is correct |
3 | Correct | 0 ms | 9832 KB | Output is correct |
4 | Incorrect | 0 ms | 9832 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 9832 KB | Output is correct |
2 | Correct | 0 ms | 9832 KB | Output is correct |
3 | Correct | 0 ms | 9832 KB | Output is correct |
4 | Incorrect | 0 ms | 9832 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |