# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
156032 | EntityIT | JOIOJI (JOI14_joioji) | C++14 | 102 ms | 18168 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.
#include<bits/stdc++.h>
using namespace std;
const int N = (int)2e5 + 5;
int n, prefJ[N], prefO[N], prefI[N], ans;
map< pair<int, int>, set<int> > pos;
int main() {
scanf(" %d", &n);
pos[ make_pair(prefJ[0] - prefO[0], prefO[0] - prefI[0]) ].insert(0);
for (int i = 1; i <= n; ++i) {
prefJ[i] = prefJ[i - 1];
prefO[i] = prefO[i - 1];
prefI[i] = prefI[i - 1];
char c; scanf(" %c", &c);
if (c == 'J') ++prefJ[i];
if (c == 'O') ++prefO[i];
if (c == 'I') ++prefI[i];
pos[ make_pair(prefJ[i] - prefO[i], prefO[i] - prefI[i]) ].insert(i);
}
for (auto _ : pos) {
ans = max(ans, *_.second.rbegin() - *_.second.begin() );
}
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... |