#include <bits/stdc++.h>
using namespace std;
void Solve() {
int n;
cin >> n;
vector<pair<int, int> > a(n + 1);
vector<bool> isTaken(n + 3);
for(int i = 1; i <= n; i++) {
cin >> a[i].first;
isTaken[i] = false;
a[i].second = i;
}
sort(a.begin() + 1, a.end());
isTaken[0] = true;
isTaken[n + 1] = true;
int ans = 0, curr = 0;
for(int i = 1; i <= n; i++) {
int curVal = a[i].first;
for(int j = i; j <= n; j++) {
if(a[j].first != curVal)
break;
i = j;
isTaken[a[j].second] = true;
if(!isTaken[a[j].second - 1] && !isTaken[a[j].second + 1]) {
curr++;
}
else if(isTaken[a[j].second - 1] && isTaken[a[j].second + 1]) {
curr--;
}
}
ans = max(ans, curr);
}
cout << ans + 1 << "\n";
}
int32_t main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int t = 1;
//cin >> t;
while(t--) {
Solve();
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
20 ms |
1100 KB |
Output is correct |
2 |
Correct |
20 ms |
1100 KB |
Output is correct |
3 |
Correct |
20 ms |
1100 KB |
Output is correct |
4 |
Correct |
21 ms |
1100 KB |
Output is correct |
5 |
Correct |
21 ms |
1100 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
24 ms |
1100 KB |
Output is correct |
2 |
Correct |
19 ms |
1100 KB |
Output is correct |
3 |
Correct |
23 ms |
1100 KB |
Output is correct |
4 |
Correct |
23 ms |
1100 KB |
Output is correct |
5 |
Correct |
23 ms |
1100 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
247 ms |
17516 KB |
Output is correct |
2 |
Correct |
271 ms |
17600 KB |
Output is correct |
3 |
Correct |
246 ms |
17612 KB |
Output is correct |
4 |
Correct |
290 ms |
17604 KB |
Output is correct |
5 |
Correct |
233 ms |
16964 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
248 ms |
16900 KB |
Output is correct |
2 |
Correct |
268 ms |
16836 KB |
Output is correct |
3 |
Correct |
257 ms |
16960 KB |
Output is correct |
4 |
Correct |
241 ms |
11208 KB |
Output is correct |
5 |
Correct |
220 ms |
11072 KB |
Output is correct |