# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
299662 |
2020-09-15T12:13:27 Z |
dolijan |
JJOOII 2 (JOI20_ho_t2) |
C++14 |
|
1 ms |
384 KB |
#include <bits/stdc++.h>
using namespace std;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n,k;
cin>>n>>k;
string s;
cin>>s;
int a=0,b,c,d;
while(s[a]!='J')
{
a++;
if(a==n) return cout<<-1<<endl,0;
}
b=a;
int numj=0;
while(numj<k)
{
if(b==n) return cout<<-1<<endl,0;
if(s[b]=='J') numj++;
b++;
}
c=b;
int numo=0;
while(numo<k)
{
if(c==n) return cout<<-1<<endl,0;
if(s[c]=='O') numo++;
c++;
}
d=c;
int numi=0;
while(numi<k)
{
if(d==n) return cout<<-1<<endl,0;
if(s[d]=='I') numi++;
d++;
}
int kolko=0;
for(int i=a;i<b;i++) if(s[i]!='J') kolko++;
for(int i=b;i<c;i++) if(s[i]!='O') kolko++;
for(int i=c;i<d;i++) if(s[i]!='I') kolko++;
cout<<kolko<<endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |