답안 #901515

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
901515 2024-01-09T13:47:14 Z Blagoj JOIOJI (JOI14_joioji) C++17
100 / 100
48 ms 10216 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};
    cnt[{0, 0, 0}] = -1;
    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;
}
# 결과 실행 시간 메모리 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 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 0 ms 348 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 2 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 604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 604 KB Output is correct
2 Correct 8 ms 1372 KB Output is correct
3 Correct 12 ms 2140 KB Output is correct
4 Correct 24 ms 3420 KB Output is correct
5 Correct 38 ms 5600 KB Output is correct
6 Correct 48 ms 5596 KB Output is correct
7 Correct 47 ms 6620 KB Output is correct
8 Correct 44 ms 5344 KB Output is correct
9 Correct 45 ms 5944 KB Output is correct
10 Correct 41 ms 5596 KB Output is correct
11 Correct 35 ms 8416 KB Output is correct
12 Correct 23 ms 3404 KB Output is correct
13 Correct 26 ms 2120 KB Output is correct
14 Correct 31 ms 10216 KB Output is correct
15 Correct 19 ms 1768 KB Output is correct