# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
701058 |
2023-02-19T22:34:35 Z |
Richem |
JJOOII 2 (JOI20_ho_t2) |
C++14 |
|
73 ms |
3172 KB |
#include <iostream>
#include <set>
using namespace std;
const int MAX_TAILLE = 2e5+42, INF = 1e9;
int taille, niveau;
string mot;
int cumul[MAX_TAILLE][3] = {0};
int dicho(int posDeb, int type) {
int deb = posDeb, fin = taille-1;
if(posDeb == -1 || cumul[taille][type] - cumul[posDeb][type] < niveau)
return -1;
while(deb < fin) {
int milieu = (deb + fin) / 2;
if(cumul[milieu+1][type] - cumul[posDeb][type] < niveau) {
deb = milieu+1;
}
else {
fin = milieu;
}
}
return deb;
}
int main() {
cin >> taille >> niveau;
cin >> mot;
for(int cur = 0; cur < taille; cur++) {
if(mot[cur] == 'J')
cumul[cur+1][0]++;
else if(mot[cur] == 'O')
cumul[cur+1][1]++;
else
cumul[cur+1][2]++;
for(int type = 0; type < 3; type++) {
cumul[cur+1][type] += cumul[cur][type];
}
}
int rep = INF;
for(int deb = 0; deb < taille; deb++) {
int posCur = deb;
bool bon = 1;
for(int type = 0; type < 3; type++) {
posCur = dicho(posCur, type);
if(posCur == -1)
bon = 0;
}
if(bon) {
rep = min(rep, posCur - deb - 3 * niveau + 1);
}
}
if(rep == INF) {
cout << "-1";
}
else {
cout << rep;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
0 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 |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
0 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 |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
344 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
1 ms |
212 KB |
Output is correct |
19 |
Correct |
1 ms |
340 KB |
Output is correct |
20 |
Correct |
1 ms |
340 KB |
Output is correct |
21 |
Correct |
1 ms |
340 KB |
Output is correct |
22 |
Correct |
1 ms |
240 KB |
Output is correct |
23 |
Correct |
1 ms |
212 KB |
Output is correct |
24 |
Correct |
1 ms |
340 KB |
Output is correct |
25 |
Correct |
1 ms |
340 KB |
Output is correct |
26 |
Correct |
1 ms |
340 KB |
Output is correct |
27 |
Correct |
1 ms |
340 KB |
Output is correct |
28 |
Correct |
1 ms |
340 KB |
Output is correct |
29 |
Correct |
1 ms |
340 KB |
Output is correct |
30 |
Correct |
1 ms |
340 KB |
Output is correct |
31 |
Correct |
0 ms |
212 KB |
Output is correct |
32 |
Correct |
1 ms |
340 KB |
Output is correct |
33 |
Correct |
1 ms |
340 KB |
Output is correct |
34 |
Correct |
1 ms |
340 KB |
Output is correct |
35 |
Correct |
0 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
0 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 |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
344 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
1 ms |
212 KB |
Output is correct |
19 |
Correct |
1 ms |
340 KB |
Output is correct |
20 |
Correct |
1 ms |
340 KB |
Output is correct |
21 |
Correct |
1 ms |
340 KB |
Output is correct |
22 |
Correct |
1 ms |
240 KB |
Output is correct |
23 |
Correct |
1 ms |
212 KB |
Output is correct |
24 |
Correct |
1 ms |
340 KB |
Output is correct |
25 |
Correct |
1 ms |
340 KB |
Output is correct |
26 |
Correct |
1 ms |
340 KB |
Output is correct |
27 |
Correct |
1 ms |
340 KB |
Output is correct |
28 |
Correct |
1 ms |
340 KB |
Output is correct |
29 |
Correct |
1 ms |
340 KB |
Output is correct |
30 |
Correct |
1 ms |
340 KB |
Output is correct |
31 |
Correct |
0 ms |
212 KB |
Output is correct |
32 |
Correct |
1 ms |
340 KB |
Output is correct |
33 |
Correct |
1 ms |
340 KB |
Output is correct |
34 |
Correct |
1 ms |
340 KB |
Output is correct |
35 |
Correct |
0 ms |
340 KB |
Output is correct |
36 |
Correct |
67 ms |
2788 KB |
Output is correct |
37 |
Correct |
73 ms |
2916 KB |
Output is correct |
38 |
Correct |
73 ms |
2916 KB |
Output is correct |
39 |
Correct |
60 ms |
2916 KB |
Output is correct |
40 |
Correct |
36 ms |
3152 KB |
Output is correct |
41 |
Correct |
54 ms |
3172 KB |
Output is correct |
42 |
Correct |
68 ms |
3156 KB |
Output is correct |
43 |
Correct |
17 ms |
2148 KB |
Output is correct |
44 |
Correct |
24 ms |
2508 KB |
Output is correct |
45 |
Correct |
28 ms |
3148 KB |
Output is correct |
46 |
Correct |
32 ms |
3052 KB |
Output is correct |
47 |
Correct |
29 ms |
3156 KB |
Output is correct |
48 |
Correct |
29 ms |
3152 KB |
Output is correct |
49 |
Correct |
19 ms |
2148 KB |
Output is correct |
50 |
Correct |
28 ms |
3052 KB |
Output is correct |
51 |
Correct |
30 ms |
3152 KB |
Output is correct |
52 |
Correct |
11 ms |
3044 KB |
Output is correct |
53 |
Correct |
12 ms |
3052 KB |
Output is correct |
54 |
Correct |
30 ms |
3172 KB |
Output is correct |
55 |
Correct |
15 ms |
3044 KB |
Output is correct |
56 |
Correct |
7 ms |
3052 KB |
Output is correct |