# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
152587 |
2019-09-08T13:44:30 Z |
oolimry |
JOIOJI (JOI14_joioji) |
C++14 |
|
5 ms |
632 KB |
#include <bits/stdc++.h>
using namespace std;
int main(){
ios_base::sync_with_stdio(false);
int n;
cin >> n;
string s;
cin >> s;
int I = 0;
int J = 0;
int O = 0;
typedef pair<int,int> ii;
map<ii,int> m;
for(int i = 0;i < n;i++){
if(s[i] == 'I') I++;
else if(s[i] == 'O') O++;
else J++;
m[ii(J-O,I-O)] = i;
}
I = 0, J = 0, O = 0;
int ans = 0;
for(int i = 0;i < n;i++){
if(m[ii(O-J,O-I)] > i)
ans = max(ans,m[ii(O-J,O-I)] - i + 1);
if(s[i] == 'I') I++;
else if(s[i] == 'O') O++;
else J++;
}
if(ans == 1) ans = 0;
cout << ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
632 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |