Submission #173449

#TimeUsernameProblemLanguageResultExecution timeMemory
173449ahgus89JOIOJI (JOI14_joioji)C++14
0 / 100
2 ms504 KiB
#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 (stderr)

joioji.cpp: In function 'int main()':
joioji.cpp:32:16: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   int mid=lo+hi+1>>1;
           ~~~~~^~
joioji.cpp:17:9: warning: unused variable 'temp' [-Wunused-variable]
  int i, temp=0;
         ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...