#include<bits/stdc++.h>
using namespace std;
using ll = long long;
ll n, ans, p, j, s, x;
int main() {
ll i, t, r;
cin >> n;
map < int, bool > Used;
vector < pair < ll, ll > > v;
v.push_back(make_pair(-1, -1));
for ( i = 1; i <= n; i ++) {
cin >> x;
v.push_back(make_pair(x, i));
}
ans = 0;
sort ( v.begin(), v.end());
r = 0;
for ( i = n; i >= 1; i --) {
x = v[i].second;
if ( v[i].first != v[i - 1].first) {
ans ++;
if ( Used[x + 1] == 1) ans --;
if ( Used[x - 1] == 1) ans --;
Used[x] = 1;
}
r = max (r, ans);
}
cout << r << endl;
}
Compilation message
gw.cpp: In function 'int main()':
gw.cpp:7:8: warning: unused variable 't' [-Wunused-variable]
7 | ll i, t, r;
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
25 ms |
2376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
95 ms |
6644 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1065 ms |
58188 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1065 ms |
55540 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |