Submission #77224

#TimeUsernameProblemLanguageResultExecution timeMemory
77224farukkastamonudaDifference (POI11_roz)C++14
100 / 100
717 ms25936 KiB
#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)

roz.cpp: In function 'int main()':
roz.cpp:12:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&n);
     ~~~~~^~~~~~~~~
roz.cpp:15:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf(" %c",&ch);
         ~~~~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...