답안 #701054

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
701054 2023-02-19T22:10:16 Z Richem JJOOII 2 (JOI20_ho_t2) C++14
13 / 100
2000 ms 856 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');
            total++;
        }

        if(nbI == niveau) {
            rep = min(rep, total - 3 * niveau);
        }
    }
    if(rep == INF) {
        cout << "-1";
    }
    else {
        cout << rep;
    }    
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 300 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 300 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 0 ms 300 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 296 KB Output is correct
20 Correct 1 ms 300 KB Output is correct
21 Correct 2 ms 212 KB Output is correct
22 Correct 2 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 2 ms 212 KB Output is correct
25 Correct 2 ms 212 KB Output is correct
26 Correct 3 ms 212 KB Output is correct
27 Correct 2 ms 296 KB Output is correct
28 Correct 2 ms 212 KB Output is correct
29 Correct 2 ms 300 KB Output is correct
30 Correct 2 ms 300 KB Output is correct
31 Correct 1 ms 300 KB Output is correct
32 Correct 2 ms 212 KB Output is correct
33 Correct 3 ms 212 KB Output is correct
34 Correct 3 ms 212 KB Output is correct
35 Correct 3 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 300 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 0 ms 300 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 296 KB Output is correct
20 Correct 1 ms 300 KB Output is correct
21 Correct 2 ms 212 KB Output is correct
22 Correct 2 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 2 ms 212 KB Output is correct
25 Correct 2 ms 212 KB Output is correct
26 Correct 3 ms 212 KB Output is correct
27 Correct 2 ms 296 KB Output is correct
28 Correct 2 ms 212 KB Output is correct
29 Correct 2 ms 300 KB Output is correct
30 Correct 2 ms 300 KB Output is correct
31 Correct 1 ms 300 KB Output is correct
32 Correct 2 ms 212 KB Output is correct
33 Correct 3 ms 212 KB Output is correct
34 Correct 3 ms 212 KB Output is correct
35 Correct 3 ms 212 KB Output is correct
36 Correct 7 ms 824 KB Output is correct
37 Correct 7 ms 856 KB Output is correct
38 Correct 7 ms 848 KB Output is correct
39 Execution timed out 2079 ms 852 KB Time limit exceeded
40 Halted 0 ms 0 KB -