# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
20801 | jjwdi0 | JOIOJI (JOI14_joioji) | C++11 | 43 ms | 7896 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;
typedef pair<int, int> pr;
int N, J, O, ans;
char A[200005];
map<pr, int> m;
int main() {
scanf("%d %s", &N, A);
m[pr(0, 0)] = -1;
for(int i=0; i<N; i++) {
if(A[i] == 'J') J++;
if(A[i] == 'O') O++;
if(A[i] == 'I') J--, O--;
if(m.find(pr(J, O)) != m.end()) ans = max(ans, i - m[pr(J, O)]);
else m[pr(J, O)] = i;
}
printf("%d\n", ans);
}
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... |