답안 #1044573

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1044573 2024-08-05T10:59:08 Z juicy JOIOJI (JOI14_joioji) C++17
100 / 100
32 ms 5980 KB
#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);

    int n; cin >> n;
    map<array<int, 2>, int> mp;
    mp[{0, 0}] = 0;
    array<int, 2> dif{};
    int res = 0;
    for (int i = 1; i <= n; ++i) {
        char c; cin >> c;
        if (c == 'J') {
            ++dif[0], ++dif[1];
        } else if (c == 'O') {
            --dif[0];
        } else {
            --dif[1];
        }
        if (mp.count({dif[0], dif[1]})) {
            res = max(res, i - mp[{dif[0], dif[1]}]);
        } else {
            mp[{dif[0], dif[1]}] = i;
        }
    }
    cout << res;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 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 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 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 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 604 KB Output is correct
2 Correct 5 ms 860 KB Output is correct
3 Correct 8 ms 1372 KB Output is correct
4 Correct 13 ms 2276 KB Output is correct
5 Correct 20 ms 3420 KB Output is correct
6 Correct 26 ms 3412 KB Output is correct
7 Correct 31 ms 3908 KB Output is correct
8 Correct 32 ms 3412 KB Output is correct
9 Correct 26 ms 3696 KB Output is correct
10 Correct 26 ms 3420 KB Output is correct
11 Correct 21 ms 4948 KB Output is correct
12 Correct 19 ms 2140 KB Output is correct
13 Correct 15 ms 1620 KB Output is correct
14 Correct 19 ms 5980 KB Output is correct
15 Correct 13 ms 1116 KB Output is correct