Submission #885127

#TimeUsernameProblemLanguageResultExecution timeMemory
885127vjudge1Difference (POI11_roz)C++17
100 / 100
75 ms1528 KiB
#include<bits/stdc++.h> using namespace std; const int N=26; int res=0, n; int pre[N][N], premin[N][N], last[N][N]; string s; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin>>n>>s; for(int i=0; i<N; i++) for(int j=0; j<N; j++) premin[i][j]=1e9; for(int i=0; i<n; i++) { int a=s[i]-'a'; for(int b=0; b<N; b++) if(a!=b) { pre[a][b]++; res=max(res, pre[a][b]-premin[a][b]); premin[b][a]=min(premin[b][a], last[b][a]); last[b][a]=--pre[b][a]; res=max(res, pre[b][a]-premin[b][a]); } } cout<<res; return 0; }
#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...