# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
140853 | 2019-08-05T17:40:56 Z | shafinalam | Difference (POI11_roz) | C++14 | 665 ms | 17164 KB |
#include <bits/stdc++.h> using namespace std; #define ff first #define ss second const int mxn = 1e6+5; typedef pair<int,int>pii; #define input freopen("in.txt","r",stdin) #define output freopen("out.txt","w",stdout) #define all(v) v.begin(), v.end() vector<pii>arr[30]; pii tmp[mxn]; int main() { //input; //output; int n; scanf("%d", &n); char ch; for(int i = 0; i < n; i++) { scanf(" %c", &ch); arr[ch-'a'].push_back(make_pair(i, ch-'a')); } int ans = -1; for(int i = 0; i < 26; i++) { for(int r = 0; r < 26; r++) { if(i==r) continue; merge(all(arr[i]), all(arr[r]), tmp); int k = arr[i].size()+arr[r].size(); int sum = 0, best = -(1<<30); for(int j = 0; j < k; j++) { if(tmp[j].ss==i) { sum++; best++; } else { best = sum-1; sum = max(sum-1, 0); } ans = max(ans, best); } } } printf("%d\n", ans); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 256 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 504 KB | Output is correct |
2 | Correct | 2 ms | 472 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 67 ms | 1516 KB | Output is correct |
2 | Correct | 2 ms | 252 KB | Output is correct |
3 | Correct | 6 ms | 504 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 662 ms | 10528 KB | Output is correct |
2 | Correct | 2 ms | 256 KB | Output is correct |
3 | Correct | 385 ms | 8516 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 665 ms | 10532 KB | Output is correct |
2 | Correct | 503 ms | 8904 KB | Output is correct |
3 | Correct | 178 ms | 9208 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 660 ms | 10696 KB | Output is correct |
2 | Correct | 237 ms | 14516 KB | Output is correct |
3 | Correct | 194 ms | 11084 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 665 ms | 10448 KB | Output is correct |
2 | Correct | 220 ms | 17164 KB | Output is correct |
3 | Correct | 199 ms | 10556 KB | Output is correct |