Submission #901512

#TimeUsernameProblemLanguageResultExecution timeMemory
901512BlagojJOIOJI (JOI14_joioji)C++17
95 / 100
49 ms10464 KiB
#include <bits/stdc++.h> using namespace std; #define endl '\n' #define ll long long #define all(x) (x).begin(), (x).end() int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n; cin >> n; string s; cin >> s; map<vector<int>, int> cnt; vector<int> occ(3); cnt[occ]++; int ans = 0; for (int i = 0; i < n; i++) { if (s[i] == 'J') occ[0]++; if (s[i] == 'O') occ[1]++; if (s[i] == 'I') occ[2]++; int mn = occ[0]; for (int i = 1; i < 3; i++) mn = min(mn, occ[i]); for (int i = 0; i < 3; i++) occ[i] -= mn; if (cnt[occ]) ans = max(ans, i - cnt[occ]); else cnt[occ] = i; } cout << ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...