Submission #901513

#TimeUsernameProblemLanguageResultExecution timeMemory
901513BlagojJOIOJI (JOI14_joioji)C++17
95 / 100
60 ms10204 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), null = {0, 0, 0}; 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] || occ == null) 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...