# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
91171 | 2018-12-26T12:45:24 Z | davitmarg | Money (IZhO17_money) | C++17 | 2 ms | 372 KB |
/* DEATH-MATCH Davit-Marg */ #include <iostream> #include <algorithm> #include <cmath> #include <vector> #include <string> #include <cstring> #include <map> #include <set> #include <queue> #include <deque> #include <stack> #include <iterator> #include <ctype.h> #include <stdlib.h> #include <fstream> #define mod 1000000007ll #define LL long long #define LD long double #define MP make_pair #define PB push_back using namespace std; int n,ans,a[1000006],l; set<int> s; stack<int> st; set<int>::iterator it; int main() { cin >> n; ans = 1; for (int i = 1; i <= n; i++) scanf("%d", a+i); s.insert(0); it = s.end(); for (int i = 1; i <= n; i++) { if ((a[i] < a[i - 1]) || it != s.end() && (*it) < a[i] ) { l = a[i]; it = s.upper_bound(l); ans++; while (!st.empty()) { s.insert(st.top()); st.pop(); } } st.push(a[i]); } cout << ans << endl; return 0; } /* 6 1 3 5 2 4 6 */
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Incorrect | 2 ms | 372 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Incorrect | 2 ms | 372 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Incorrect | 2 ms | 372 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Incorrect | 2 ms | 372 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |