Submission #503581

#TimeUsernameProblemLanguageResultExecution timeMemory
503581lucriJJOOII 2 (JOI20_ho_t2)C++17
100 / 100
17 ms1264 KiB
#include <iostream> using namespace std; int n,k,pj[200010],po[200010],pi[200010],aj,ao,ai,nrj,nro,nri,ans=-1; char c; int main() { cin>>n>>k; for(int i=1;i<=n;++i) { cin>>c; if(c=='J') pj[++nrj]=i; if(c=='O') po[++nro]=i; if(c=='I') pi[++nri]=i; } int c=nri,a=nrj,b=nro; for(int c=nri;c>=k;--c) { while(pi[c-k+1]<po[b]) --b; if(b<k) break; while(po[b-k+1]<pj[a]) --a; if(a<k) break; if(ans==-1||ans>pi[c]-pj[a-k+1]+1-3*k) ans=pi[c]-pj[a-k+1]+1-3*k; } cout<<ans; return 0; }

Compilation message (stderr)

ho_t2.cpp: In function 'int main()':
ho_t2.cpp:18:9: warning: unused variable 'c' [-Wunused-variable]
   18 |     int c=nri,a=nrj,b=nro;
      |         ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...