# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
77224 | farukkastamonuda | Difference (POI11_roz) | C++14 | 717 ms | 25936 KiB |
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>
#define li 1000005
#define fi first
#define se second
#define mp make_pair
using namespace std;
int n,c,c2,ans;
char s[li],ch;
vector< pair<int,int> > v[35];
pair<int,int> sw[li];
int main(){
scanf("%d",&n);
//scanf("%s",s+1);
for(int i=1;i<=n;i++){
scanf(" %c",&ch);
v[ch-'a'].push_back(mp(i,ch-'a'));
}
for(int i=0;i<26;i++){
for(int j=0;j<26;j++){
merge(v[i].begin(),v[i].end(),v[j].begin(),v[j].end(),sw);
int gh=(int)v[i].size()+(int)v[j].size();
c2=-(1<<30);c=0;
for(int k=0;k<gh;k++){
if(sw[k].se==i){
c++;
c2++;
}
else{
c2=c-1;
c--;
c=max(0,c);
}
ans=max(ans,c2);
}
}
}
printf("%d\n",ans);
return 0;
}
Compilation message (stderr)
# | 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... |
# | 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... |