#include <bits/stdc++.h>
using namespace std;
constexpr int NMAX = 1e6 + 5;
int N;
int A[NMAX];
set <int> S;
int main () {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cin >> N;
for (int i = 1; i <= N; ++ i )
cin >> A[i];
int ans = 0;
for (int i = 1; i <= N; ++ i ) {
++ ans;
auto it = S.upper_bound(A[i]);
bool Up = 0;
int TopCap = 0;
if (it == S.end()) Up = true;
else TopCap = *it;
S.insert(A[i]);
while (i < N && A[i+1] > A[i] && (Up || A[i+1] <= TopCap) ) {
S.insert(A[i+1]);
++ i;
}
}
cout << ans << '\n';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
224 KB |
Output is correct |
6 |
Correct |
0 ms |
224 KB |
Output is correct |
7 |
Incorrect |
1 ms |
224 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
224 KB |
Output is correct |
6 |
Correct |
0 ms |
224 KB |
Output is correct |
7 |
Incorrect |
1 ms |
224 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
224 KB |
Output is correct |
6 |
Correct |
0 ms |
224 KB |
Output is correct |
7 |
Incorrect |
1 ms |
224 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
224 KB |
Output is correct |
6 |
Correct |
0 ms |
224 KB |
Output is correct |
7 |
Incorrect |
1 ms |
224 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |