# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
901513 |
2024-01-09T13:46:03 Z |
Blagoj |
JOIOJI (JOI14_joioji) |
C++17 |
|
60 ms |
10204 KB |
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll long long
#define all(x) (x).begin(), (x).end()
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;
cin >> n;
string s;
cin >> s;
map<vector<int>, int> cnt;
vector<int> occ(3), null = {0, 0, 0};
int ans = 0;
for (int i = 0; i < n; i++) {
if (s[i] == 'J') occ[0]++;
if (s[i] == 'O') occ[1]++;
if (s[i] == 'I') occ[2]++;
int mn = occ[0];
for (int i = 1; i < 3; i++) mn = min(mn, occ[i]);
for (int i = 0; i < 3; i++) occ[i] -= mn;
if (cnt[occ] || occ == null) ans = max(ans, i - cnt[occ]);
else cnt[occ] = i;
}
cout << ans;
}
# |
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 |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
344 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 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
600 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
604 KB |
Output is correct |
5 |
Correct |
1 ms |
604 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 |
604 KB |
Output is correct |
9 |
Correct |
1 ms |
604 KB |
Output is correct |
10 |
Correct |
1 ms |
600 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
604 KB |
Output is correct |
2 |
Correct |
8 ms |
1292 KB |
Output is correct |
3 |
Correct |
12 ms |
2268 KB |
Output is correct |
4 |
Correct |
25 ms |
3672 KB |
Output is correct |
5 |
Correct |
40 ms |
5544 KB |
Output is correct |
6 |
Correct |
54 ms |
5676 KB |
Output is correct |
7 |
Correct |
60 ms |
6620 KB |
Output is correct |
8 |
Correct |
48 ms |
5340 KB |
Output is correct |
9 |
Correct |
49 ms |
5856 KB |
Output is correct |
10 |
Correct |
46 ms |
5600 KB |
Output is correct |
11 |
Correct |
40 ms |
8580 KB |
Output is correct |
12 |
Correct |
25 ms |
3424 KB |
Output is correct |
13 |
Correct |
29 ms |
2296 KB |
Output is correct |
14 |
Correct |
35 ms |
10204 KB |
Output is correct |
15 |
Correct |
20 ms |
2020 KB |
Output is correct |