# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
701053 |
2023-02-19T22:07:26 Z |
Richem |
JJOOII 2 (JOI20_ho_t2) |
C++14 |
|
0 ms |
212 KB |
#include <iostream>
using namespace std;
const int INF = 1e9;
int taille, niveau;
string mot;
int main() {
cin >> taille >> niveau;
cin >> mot;
int rep = INF;
for(int deb = 0; deb < taille; deb++) {
if(mot[deb] != 'J') {
continue;
}
int curId = deb;
int nbJ = 0;
int total = 0;
while(curId < taille && nbJ < niveau) {
nbJ += (mot[curId++] == 'J');
total++;
}
if(nbJ != niveau) {
continue;
}
int nbO = 0;
while(curId < taille && nbO < niveau) {
nbO += (mot[curId++] == 'O');
total++;
}
if(nbO != niveau) {
continue;
}
int nbI = 0;
while(curId < taille && nbI < niveau) {
nbI += (mot[curId++] == 'I');
}
if(nbI == niveau) {
rep = min(rep, total - 2 * niveau);
}
}
if(rep == INF) {
cout << "-1";
}
else {
cout << rep;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |