This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <cstdio>
#include <algorithm>
#include <queue>
#include <utility>
using namespace std;
typedef pair<int,int> pi;
int v[1000005],n;
priority_queue<pi,vector<pi>,greater<pi> > pq;
int main(){
scanf("%d",&n);
for (int i=1; i<=n; i++) {
int t;
scanf("%d",&t);
v[i] = 1;
pq.push(pi(t,i));
}
int ct = 1, res = 1;
while (!pq.empty()) {
int x = pq.top().first;
while (!pq.empty() && pq.top().first == x) {
int pos = pq.top().second;
ct += v[pos-1] + v[pos+1] - 1;
v[pos] = 0;
pq.pop();
}
res = max(res,ct);
}
printf("%d",res);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |