Submission #996812

#TimeUsernameProblemLanguageResultExecution timeMemory
996812onbertJOIOJI (JOI14_joioji)C++17
100 / 100
30 ms6376 KiB
#include <bits/stdc++.h> using namespace std; #define int long long signed main() { ios::sync_with_stdio(0); cin.tie(0); int n; cin >> n; string s; cin >> s; int ans = 0, J = 0, O = 0, I = 0; map<pair<int,int>, int> m; m[{0, 0}] = -1; for (int i=0;i<n;i++) { if (s[i]=='J') J++; if (s[i]=='O') O++; if (s[i]=='I') I++; if (!m.count({O-J, I-J})) m[{O-J, I-J}] = i; else ans = max(i - m[{O-J, I-J}], ans); } cout << ans << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...