Submission #748380

#TimeUsernameProblemLanguageResultExecution timeMemory
748380AlanJOIOJI (JOI14_joioji)C++17
0 / 100
1 ms300 KiB
#include <bits/stdc++.h> using namespace std; bool ok (int u, string s) { vector<int> cnt (26); int p1 = 0, p2 = u*3-1; for (int i = p1; i <= p2; i++) cnt[s[i]-'A']++; if (cnt['J'-'A'] == u && cnt['O'-'A'] == u && cnt['I'-'A'] == u) return true; while (p2+1 < (int) s.size()) { cnt[s[p1]-'A']--; p1++; p2++; cnt[s[p2]-'A']++; if (cnt['J'-'A'] == u && cnt['O'-'A'] == u && cnt['I'-'A'] == u) return true; } return false; } int main () { int n; string s; cin >> n >> s; int l = 0, r = n/3 + 1; while (l+1 < r) { int mid = (l+r)/2; if (ok(mid, s)) l = mid; else r = mid; } cout << l*3 << '\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...