#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int MXN = 1000 * 1000 + 3;
int a[MXN];
signed main() {
std::ios::sync_with_stdio(0);
std::cin.tie(0);
int n; cin >> n;
for(int i = 1; i <= n; i++) {
cin >> a[i];
}
set<int> s = {MXN};
int ans = 0;
for(int j = 1, i = 1; i <= n; i = j) {
j = i + 1;
int x = *s.upper_bound(a[i]);
s.insert(a[j]);
while(j <= n && a[j - 1] <= a[j] && a[j] <= x)
s.insert(a[j++]);
ans++;
}
cout << ans << '\n';
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |