Submission #901512

# Submission time Handle Problem Language Result Execution time Memory
901512 2024-01-09T13:43:38 Z Blagoj JOIOJI (JOI14_joioji) C++17
95 / 100
49 ms 10464 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);
    cnt[occ]++;
    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]) 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 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 348 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 344 KB Output is correct
9 Incorrect 1 ms 348 KB Output isn't correct
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory 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 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 600 KB Output is correct
9 Correct 1 ms 604 KB Output is correct
10 Correct 1 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 596 KB Output is correct
2 Correct 7 ms 1372 KB Output is correct
3 Correct 12 ms 2140 KB Output is correct
4 Correct 24 ms 3540 KB Output is correct
5 Correct 40 ms 5580 KB Output is correct
6 Correct 49 ms 5856 KB Output is correct
7 Correct 49 ms 6648 KB Output is correct
8 Correct 46 ms 5864 KB Output is correct
9 Correct 46 ms 6064 KB Output is correct
10 Correct 42 ms 5620 KB Output is correct
11 Correct 37 ms 8672 KB Output is correct
12 Correct 24 ms 3624 KB Output is correct
13 Correct 27 ms 2300 KB Output is correct
14 Correct 32 ms 10464 KB Output is correct
15 Correct 19 ms 1768 KB Output is correct