# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
173449 | 2020-01-04T07:16:06 Z | ahgus89 | JOIOJI (JOI14_joioji) | C++14 | 2 ms | 504 KB |
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; int n, m, k, ans, mod=1e9+7; int J[202020], O[202020], I[202020]; bool chk(int x) { for(int i=0;i+3*x<=n;i++) if(J[i+3*x]-J[i]==x&&O[i+3*x]-O[i]==x&&I[i+3*x]-I[i]==x) return 1; return 0; } int main() { ios_base::sync_with_stdio(false); cin.tie(0); int i, temp=0; string s; cin>>n>>s; for(i=1;i<=n;i++) { J[i]=J[i-1]; O[i]=O[i-1]; I[i]=I[i-1]; if(s[i-1]=='J') J[i]++; if(s[i-1]=='O') O[i]++; if(s[i-1]=='I') I[i]++; } int lo=0, hi=n/3; while(lo<hi) { int mid=lo+hi+1>>1; if(chk(mid)) lo=mid; else hi=mid-1; } cout<<lo*3; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 376 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Incorrect | 2 ms | 376 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 504 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |