#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;
#define ll long long
#define fff(i, a, b) for(ll i = a; i < b; i++)
#define MAXN 1000006
bool sim[MAXN];
int main(){
ll n; cin >> n;
vector<pair<ll, ll>> v;
fff(i, 0, n){
ll a; cin >> a;
v.emplace_back(a, i+1);
}
sort(v.rbegin(), v.rend());
ll best = 0;
ll cur = 0;
ll prev = -1;
fff(i, 0, n){
auto [h, j] = v[i];
if (prev != h && cur > best) best = cur;
sim[j] = 1;
cur++;
if (sim[j+1]) cur--;
if (sim[j-1]) cur--;
prev = h;
}
cout << best << endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
452 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
20 ms |
2872 KB |
Output is correct |
2 |
Correct |
19 ms |
2896 KB |
Output is correct |
3 |
Correct |
19 ms |
2768 KB |
Output is correct |
4 |
Correct |
19 ms |
2768 KB |
Output is correct |
5 |
Correct |
23 ms |
2708 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
28 ms |
3276 KB |
Output is correct |
2 |
Correct |
21 ms |
3020 KB |
Output is correct |
3 |
Correct |
28 ms |
3168 KB |
Output is correct |
4 |
Correct |
38 ms |
3276 KB |
Output is correct |
5 |
Correct |
28 ms |
3384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
349 ms |
26272 KB |
Output is correct |
2 |
Correct |
321 ms |
26520 KB |
Output is correct |
3 |
Correct |
307 ms |
26264 KB |
Output is correct |
4 |
Correct |
364 ms |
26316 KB |
Output is correct |
5 |
Correct |
308 ms |
25684 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
298 ms |
25820 KB |
Output is correct |
2 |
Correct |
314 ms |
25852 KB |
Output is correct |
3 |
Correct |
307 ms |
25852 KB |
Output is correct |
4 |
Correct |
203 ms |
19864 KB |
Output is correct |
5 |
Correct |
196 ms |
19860 KB |
Output is correct |