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 <bits/stdc++.h>
using namespace std;
#define pb push_back
#define F first
#define S second
#define pii pair<int,int>
vector<pii> t;
bool x[1000100];
int n;
int main(){
cin>>n;
for(int i = 0 ; i < n; i++){
int k ;
cin>>k;
t.pb(pii(k , i + 1));
x[i+1] = 1;
}
sort(t.begin() , t.end());
int maxxi = 1;
int curr = 1;
for(int i = 0 ; i < n; i++){
pii u = t[i];
x[u.S] = 0;
if(i && t[i-1].F != u.F){
maxxi = max(maxxi , curr);
}
if(x[u.S - 1] + x[u.S + 1] == 2) curr++; // Cria nova ilha
else if(x[u.S - 1] + x[u.S + 1] == 0) curr--; // Afunda uma ilha existente
}
cout<<maxxi<<endl;
}
# | 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... |