# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
217106 | jamielim | JJOOII 2 (JOI20_ho_t2) | C++14 | 5 ms | 512 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |