# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
30082 | 2017-07-22T05:07:30 Z | khsoo01 | Difference (POI11_roz) | C++11 | 206 ms | 14332 KB |
#include<bits/stdc++.h> using namespace std; const int N = 1000005; int n, sum[N], ans; char ipt[N]; vector<int> s[26]; void solve (int I) { for(int i=1;i<=n;i++) { sum[i] = sum[i-1] + (ipt[i] == I); } for(int k=0;k<26;k++) { if(k == I) continue; int mn = 0; for(int i=1;i<s[k].size();i++) { ans = max(ans, sum[s[k][i]] - i - mn); mn = min(mn, sum[s[k][i-1]] - i); } } } int main() { scanf("%d%s",&n,ipt+1); for(int i=1;i<=n;i++) { ipt[i] -= 'a'; s[ipt[i]].push_back(i); } for(int i=0;i<26;i++) s[i].push_back(n); for(int i=0;i<26;i++) solve(i); printf("%d\n",ans); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 6904 KB | Output is correct |
2 | Correct | 0 ms | 6904 KB | Output is correct |
3 | Correct | 0 ms | 6904 KB | Output is correct |
4 | Correct | 0 ms | 6904 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 6904 KB | Output is correct |
2 | Correct | 0 ms | 6904 KB | Output is correct |
3 | Correct | 0 ms | 6904 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 6904 KB | Output is correct |
2 | Correct | 0 ms | 6904 KB | Output is correct |
3 | Correct | 0 ms | 6904 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 6904 KB | Output is correct |
2 | Correct | 0 ms | 6904 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 7036 KB | Output is correct |
2 | Correct | 0 ms | 6904 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 16 ms | 7312 KB | Output is correct |
2 | Correct | 0 ms | 6904 KB | Output is correct |
3 | Correct | 0 ms | 7036 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 199 ms | 14332 KB | Output is correct |
2 | Correct | 0 ms | 6904 KB | Output is correct |
3 | Correct | 143 ms | 11480 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 206 ms | 13980 KB | Output is correct |
2 | Correct | 136 ms | 13456 KB | Output is correct |
3 | Correct | 119 ms | 13684 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 183 ms | 14328 KB | Output is correct |
2 | Correct | 133 ms | 14164 KB | Output is correct |
3 | Correct | 133 ms | 12136 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 199 ms | 13928 KB | Output is correct |
2 | Correct | 136 ms | 12112 KB | Output is correct |
3 | Correct | 133 ms | 14200 KB | Output is correct |