Submission #156045

# Submission time Handle Problem Language Result Execution time Memory
156045 2019-10-03T02:25:51 Z atoiz JOIOJI (JOI14_joioji) C++14
100 / 100
32 ms 3944 KB
#include <iostream>
#include <unordered_map>
#include <algorithm>

using namespace std;

unordered_map<long long, int> min_idx;
const int MAXN = 200007;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n;
    cin >> n;

    long long cur = 0;
    min_idx[cur] = 0;

    int ans = 0;
    for (int i = 1; i <= n; ++i) {
        char ch;
        cin >> ch;
        if (ch == 'I') cur += 1;
        else if (ch == 'O') cur += MAXN;
        else cur -= MAXN + 1;

        int min_i = (min_idx.find(cur) == min_idx.end() ? (min_idx[cur] = i) : min_idx[cur]);
        ans = max(ans, i - min_i);
    }
    cout << ans << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 3 ms 380 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 3 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 6 ms 760 KB Output is correct
3 Correct 8 ms 1144 KB Output is correct
4 Correct 14 ms 1784 KB Output is correct
5 Correct 18 ms 2216 KB Output is correct
6 Correct 21 ms 2216 KB Output is correct
7 Correct 27 ms 3240 KB Output is correct
8 Correct 22 ms 2216 KB Output is correct
9 Correct 21 ms 2352 KB Output is correct
10 Correct 22 ms 2216 KB Output is correct
11 Correct 29 ms 3468 KB Output is correct
12 Correct 16 ms 1400 KB Output is correct
13 Correct 14 ms 1016 KB Output is correct
14 Correct 32 ms 3944 KB Output is correct
15 Correct 15 ms 764 KB Output is correct