#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define fi first
#define se second
constexpr int MAXN = 1e6 + 42;
bool isl[MAXN];
int main() {
ios::sync_with_stdio(false);
int N;
cin >> N;
vector<pair<int, int>> V(N);
for (int i = 0; i < N; i++) {
cin >> V[i].fi;
V[i].se = i + 1;
}
sort(V.rbegin(), V.rend());
int res = 0;
int cur = 0;
for (int i = 0; i < N; i++) {
cur++;
isl[V[i].se] = true;
if (isl[V[i].se + 1]) {
cur--;
}
if (isl[V[i].se - 1]) {
cur--;
}
if (i == N - 1 || V[i].fi != V[i + 1].fi) {
res = max(res, cur);
}
}
cout << res << endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
504 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
3 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
380 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
23 ms |
1528 KB |
Output is correct |
2 |
Correct |
23 ms |
1528 KB |
Output is correct |
3 |
Correct |
23 ms |
1528 KB |
Output is correct |
4 |
Correct |
23 ms |
1528 KB |
Output is correct |
5 |
Correct |
23 ms |
1528 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
27 ms |
2012 KB |
Output is correct |
2 |
Correct |
20 ms |
1912 KB |
Output is correct |
3 |
Correct |
27 ms |
2040 KB |
Output is correct |
4 |
Correct |
27 ms |
2040 KB |
Output is correct |
5 |
Correct |
26 ms |
2040 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
289 ms |
18508 KB |
Output is correct |
2 |
Correct |
284 ms |
18488 KB |
Output is correct |
3 |
Correct |
281 ms |
18552 KB |
Output is correct |
4 |
Correct |
281 ms |
18452 KB |
Output is correct |
5 |
Correct |
270 ms |
17856 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
279 ms |
17912 KB |
Output is correct |
2 |
Correct |
282 ms |
17836 KB |
Output is correct |
3 |
Correct |
279 ms |
17808 KB |
Output is correct |
4 |
Correct |
229 ms |
12024 KB |
Output is correct |
5 |
Correct |
231 ms |
11996 KB |
Output is correct |