Submission #1044573

#TimeUsernameProblemLanguageResultExecution timeMemory
1044573juicyJOIOJI (JOI14_joioji)C++17
100 / 100
32 ms5980 KiB
#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; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...