# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
375153 | 2021-03-09T03:46:09 Z | AdiZer0 | Po (COCI21_po) | C++17 | 14 ms | 1132 KB |
#include <bits/stdc++.h> #define pb push_back #define whole(x) x.begin(), x.end() #define sz(x) (int)x.size() using namespace std; typedef long long ll; typedef long double ld; const int N = (int)1e5 + 8; const int INF = (int)1e9 + 7; const ll linf = (ll)1e15 + 2; int n, a[N]; int main() { scanf ("%d", &n); for (int i = 1; i <= n; ++i) scanf ("%d", a + i); vector<int> v; int cnt = 0; for (int i = 1; i <= n; ++i) { if (!v.empty()) { if (v.back() == a[i]) continue; while (!v.empty() && v.back() > a[i]) v.pop_back(); } if (a[i] != 0 && (v.empty() || v.back() < a[i])) ++cnt, v.pb(a[i]); } printf ("%d\n", cnt); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Correct | 6 ms | 492 KB | Output is correct |
5 | Correct | 9 ms | 620 KB | Output is correct |
6 | Correct | 14 ms | 1132 KB | Output is correct |
7 | Correct | 14 ms | 748 KB | Output is correct |