#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
const int N = 1000006;
const int INF = 100000009;
int n;
int a[N];
bool color[N];
int main()
{
ios_base::sync_with_stdio(false);
cin >> n;
for (int i = 0; i < n; i++)
cin >> a[i];
int ans = 0, mn = INF, mx = -INF;
for (int i = 0; i < n - 1; i++) {
int l = a[i];
while (i < n - 1 && a[i] < a[i + 1]) i++;
int r = a[i];
if ((l < mx && mx < r) || (l < mn && mn < r))
ans++;
mn = min(mn, l), mx = max(mx, r);
ans++;
}
cout << ans << endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |