# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
996812 |
2024-06-11T09:30:40 Z |
onbert |
JOIOJI (JOI14_joioji) |
C++17 |
|
30 ms |
6376 KB |
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main() {
ios::sync_with_stdio(0); cin.tie(0);
int n;
cin >> n;
string s;
cin >> s;
int ans = 0, J = 0, O = 0, I = 0;
map<pair<int,int>, int> m;
m[{0, 0}] = -1;
for (int i=0;i<n;i++) {
if (s[i]=='J') J++;
if (s[i]=='O') O++;
if (s[i]=='I') I++;
if (!m.count({O-J, I-J})) m[{O-J, I-J}] = i;
else ans = max(i - m[{O-J, I-J}], ans);
}
cout << ans << endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
448 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
344 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
344 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
604 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
604 KB |
Output is correct |
2 |
Correct |
4 ms |
1116 KB |
Output is correct |
3 |
Correct |
8 ms |
1372 KB |
Output is correct |
4 |
Correct |
14 ms |
2372 KB |
Output is correct |
5 |
Correct |
22 ms |
3532 KB |
Output is correct |
6 |
Correct |
26 ms |
3556 KB |
Output is correct |
7 |
Correct |
28 ms |
4064 KB |
Output is correct |
8 |
Correct |
30 ms |
3544 KB |
Output is correct |
9 |
Correct |
29 ms |
3808 KB |
Output is correct |
10 |
Correct |
28 ms |
3560 KB |
Output is correct |
11 |
Correct |
18 ms |
5132 KB |
Output is correct |
12 |
Correct |
15 ms |
2276 KB |
Output is correct |
13 |
Correct |
12 ms |
1764 KB |
Output is correct |
14 |
Correct |
20 ms |
6376 KB |
Output is correct |
15 |
Correct |
12 ms |
1492 KB |
Output is correct |