# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
696331 | dongliu0426 | Difference (POI11_roz) | C++17 | 1082 ms | 2560 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <iostream>
using namespace std;
const int N = 1e6;
int main() {
int n;
scanf("%d", &n);
static char s[N];
scanf("%s", s);
int ans = 0;
for (int i = 0; i < 26; i++)
for (int j = 0; j < 26; j++) {
static int t[N + 1];
int m = 0;
for (int k = 0; k < n; k++)
if (s[k] == 'a' + i)
t[++m] = +1;
else if (s[k] == 'a' + j)
t[++m] = -1;
int p = 0, c = 0, d = 0, mn = n;
for (int k = 1; k <= m; k++) {
c += t[k];
ans = max(ans, c - mn);
if (t[k] == -1) {
for (int k_ = p; k_ < k; k_++)
mn = min(mn, d += t[k_]);
p = k;
}
}
}
printf("%d\n", ans);
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |