Submission #998301

#TimeUsernameProblemLanguageResultExecution timeMemory
998301abczzJOIOJI (JOI14_joioji)C++17
100 / 100
34 ms6124 KiB
#include <iostream> #include <array> #include <algorithm> #include <map> #define ll long long using namespace std; ll n, f; map <array<ll, 2>, ll> mp; array <ll, 2> cur; string S; int main() { cin >> n >> S; mp[cur] = -1; for (int i=0; i<n; ++i) { if (S[i] == 'J') --cur[0], --cur[1]; else if (S[i] == 'O') ++cur[0]; else ++cur[1]; if (mp.find(cur) == mp.end()) mp[cur] = i; else { f = max(f, i-mp[cur]); } } cout << f << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...