# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
217106 | 2020-03-29T01:28:47 Z | jamielim | JJOOII 2 (JOI20_ho_t2) | C++14 | 5 ms | 512 KB |
#include <bits/stdc++.h> using namespace std; int main(){ int n,k; scanf("%d%d",&n,&k); char str[n+5]; scanf("%s",str); int joi[3];memset(joi,0,sizeof(joi)); int ans=0; for(int i=0;i<n;i++){ if(joi[0]<k){ if(str[i]=='J'){ joi[0]++; }else{ if(joi[0]==0)continue; ans++; } }else if(joi[1]<k){ if(str[i]=='O'){ joi[1]++; }else{ ans++; } }else if(joi[2]<k){ if(str[i]=='I'){ joi[2]++; }else{ ans++; } }else break; } if(joi[0]!=k||joi[1]!=k||joi[2]!=k)printf("-1"); else printf("%d",ans); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 256 KB | Output is correct |
2 | Incorrect | 5 ms | 512 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 256 KB | Output is correct |
2 | Incorrect | 5 ms | 512 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 256 KB | Output is correct |
2 | Incorrect | 5 ms | 512 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |