# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
30078 | 2017-07-22T05:05:34 Z | 김현수(#1247) | Difference (POI11_roz) | C++14 | 199 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 + 1); } } } 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 | Incorrect | 0 ms | 6904 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 6904 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 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 | Incorrect | 0 ms | 6904 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 7036 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 19 ms | 7312 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 193 ms | 14332 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 199 ms | 13980 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 186 ms | 14328 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 169 ms | 13928 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |