# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1115711 | 2024-11-20T20:40:59 Z | staszic_ojuz | JJOOII 2 (JOI20_ho_t2) | C++17 | 22 ms | 13020 KB |
#include <iostream> #include <vector> using namespace std; int main() { int n,k; string a; cin >> n >> k >> a; vector<vector<int>> pref(n,{0,0,0}); vector<int> J,O,I; if (a[0]=='J'){ pref[0][0]++; J.push_back(0); } else if (a[0]=='O'){ pref[0][1]++; O.push_back(0); } else{ pref[0][2]++; I.push_back(0); } int oski=-1; for (int i=1; i<n; i++){ pref[i][0]=pref[i-1][0]; pref[i][1]=pref[i-1][1]; pref[i][2]=pref[i-1][2]; if (a[i]=='J'){ pref[i][0]++; J.push_back(i); } else if (a[i]=='O'){ pref[i][1]++; O.push_back(i); } else{ pref[i][2]++; I.push_back(i); } } /*for (int i:J) cout << i << ' '; cout << '\n'; for (int i:O) cout << i << ' '; cout << '\n'; for (int i:I) cout << i << ' '; cout << '\n';*/ /*for (int j=0; j<3; j++){ for (int i=0; i<n; i++){ cout << pref[i][j] << ' '; } cout << '\n'; }*/ int wyn=1e9; for (int i:J){ //cout << pref[i][0]+k-2 << ' '; if (J.size()>pref[i][0]+k-2){ int aktj=J[pref[i][0]+k-2]; //cout << aktj << ' ' << pref[aktj][1]+k-2 << ' '; if (O.size()>pref[aktj][1]+k-1){ int akto=O[pref[aktj][1]+k-1]; //cout << akto << ' ' << k+pref[akto][2]-1<< ' '; if (I.size()>k+pref[akto][2]-1){ wyn=min(wyn,I[k+pref[akto][2]-1]-i-3*k+1); } } } //cout << '\n'; } if (wyn==1e9) cout << -1; else cout << wyn; return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 336 KB | Output is correct |
2 | Correct | 1 ms | 508 KB | Output is correct |
3 | Correct | 1 ms | 336 KB | Output is correct |
4 | Correct | 1 ms | 336 KB | Output is correct |
5 | Correct | 1 ms | 336 KB | Output is correct |
6 | Correct | 1 ms | 336 KB | Output is correct |
7 | Correct | 1 ms | 504 KB | Output is correct |
8 | Correct | 1 ms | 336 KB | Output is correct |
9 | Correct | 1 ms | 336 KB | Output is correct |
10 | Correct | 1 ms | 336 KB | Output is correct |
11 | Correct | 1 ms | 336 KB | Output is correct |
12 | Correct | 1 ms | 336 KB | Output is correct |
13 | Correct | 1 ms | 336 KB | Output is correct |
14 | Correct | 1 ms | 336 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 336 KB | Output is correct |
2 | Correct | 1 ms | 508 KB | Output is correct |
3 | Correct | 1 ms | 336 KB | Output is correct |
4 | Correct | 1 ms | 336 KB | Output is correct |
5 | Correct | 1 ms | 336 KB | Output is correct |
6 | Correct | 1 ms | 336 KB | Output is correct |
7 | Correct | 1 ms | 504 KB | Output is correct |
8 | Correct | 1 ms | 336 KB | Output is correct |
9 | Correct | 1 ms | 336 KB | Output is correct |
10 | Correct | 1 ms | 336 KB | Output is correct |
11 | Correct | 1 ms | 336 KB | Output is correct |
12 | Correct | 1 ms | 336 KB | Output is correct |
13 | Correct | 1 ms | 336 KB | Output is correct |
14 | Correct | 1 ms | 336 KB | Output is correct |
15 | Correct | 2 ms | 592 KB | Output is correct |
16 | Correct | 1 ms | 592 KB | Output is correct |
17 | Correct | 1 ms | 592 KB | Output is correct |
18 | Correct | 1 ms | 512 KB | Output is correct |
19 | Correct | 2 ms | 764 KB | Output is correct |
20 | Correct | 1 ms | 592 KB | Output is correct |
21 | Correct | 2 ms | 592 KB | Output is correct |
22 | Correct | 1 ms | 592 KB | Output is correct |
23 | Correct | 1 ms | 336 KB | Output is correct |
24 | Correct | 1 ms | 592 KB | Output is correct |
25 | Correct | 2 ms | 440 KB | Output is correct |
26 | Correct | 2 ms | 592 KB | Output is correct |
27 | Correct | 1 ms | 592 KB | Output is correct |
28 | Correct | 1 ms | 592 KB | Output is correct |
29 | Correct | 1 ms | 592 KB | Output is correct |
30 | Correct | 1 ms | 592 KB | Output is correct |
31 | Correct | 1 ms | 336 KB | Output is correct |
32 | Correct | 1 ms | 592 KB | Output is correct |
33 | Correct | 1 ms | 592 KB | Output is correct |
34 | Correct | 2 ms | 592 KB | Output is correct |
35 | Correct | 2 ms | 612 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 336 KB | Output is correct |
2 | Correct | 1 ms | 508 KB | Output is correct |
3 | Correct | 1 ms | 336 KB | Output is correct |
4 | Correct | 1 ms | 336 KB | Output is correct |
5 | Correct | 1 ms | 336 KB | Output is correct |
6 | Correct | 1 ms | 336 KB | Output is correct |
7 | Correct | 1 ms | 504 KB | Output is correct |
8 | Correct | 1 ms | 336 KB | Output is correct |
9 | Correct | 1 ms | 336 KB | Output is correct |
10 | Correct | 1 ms | 336 KB | Output is correct |
11 | Correct | 1 ms | 336 KB | Output is correct |
12 | Correct | 1 ms | 336 KB | Output is correct |
13 | Correct | 1 ms | 336 KB | Output is correct |
14 | Correct | 1 ms | 336 KB | Output is correct |
15 | Correct | 2 ms | 592 KB | Output is correct |
16 | Correct | 1 ms | 592 KB | Output is correct |
17 | Correct | 1 ms | 592 KB | Output is correct |
18 | Correct | 1 ms | 512 KB | Output is correct |
19 | Correct | 2 ms | 764 KB | Output is correct |
20 | Correct | 1 ms | 592 KB | Output is correct |
21 | Correct | 2 ms | 592 KB | Output is correct |
22 | Correct | 1 ms | 592 KB | Output is correct |
23 | Correct | 1 ms | 336 KB | Output is correct |
24 | Correct | 1 ms | 592 KB | Output is correct |
25 | Correct | 2 ms | 440 KB | Output is correct |
26 | Correct | 2 ms | 592 KB | Output is correct |
27 | Correct | 1 ms | 592 KB | Output is correct |
28 | Correct | 1 ms | 592 KB | Output is correct |
29 | Correct | 1 ms | 592 KB | Output is correct |
30 | Correct | 1 ms | 592 KB | Output is correct |
31 | Correct | 1 ms | 336 KB | Output is correct |
32 | Correct | 1 ms | 592 KB | Output is correct |
33 | Correct | 1 ms | 592 KB | Output is correct |
34 | Correct | 2 ms | 592 KB | Output is correct |
35 | Correct | 2 ms | 612 KB | Output is correct |
36 | Correct | 17 ms | 11764 KB | Output is correct |
37 | Correct | 22 ms | 12940 KB | Output is correct |
38 | Correct | 20 ms | 12876 KB | Output is correct |
39 | Correct | 21 ms | 12736 KB | Output is correct |
40 | Correct | 18 ms | 12884 KB | Output is correct |
41 | Correct | 19 ms | 12904 KB | Output is correct |
42 | Correct | 18 ms | 12892 KB | Output is correct |
43 | Correct | 13 ms | 8240 KB | Output is correct |
44 | Correct | 15 ms | 9944 KB | Output is correct |
45 | Correct | 18 ms | 13020 KB | Output is correct |
46 | Correct | 17 ms | 12888 KB | Output is correct |
47 | Correct | 19 ms | 12884 KB | Output is correct |
48 | Correct | 18 ms | 12868 KB | Output is correct |
49 | Correct | 14 ms | 8712 KB | Output is correct |
50 | Correct | 18 ms | 12892 KB | Output is correct |
51 | Correct | 18 ms | 12892 KB | Output is correct |
52 | Correct | 16 ms | 12076 KB | Output is correct |
53 | Correct | 18 ms | 12908 KB | Output is correct |
54 | Correct | 17 ms | 13020 KB | Output is correct |
55 | Correct | 18 ms | 13020 KB | Output is correct |
56 | Correct | 19 ms | 12960 KB | Output is correct |