# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
838010 | 2023-08-26T04:22:02 Z | vjudge1 | JJOOII 2 (JOI20_ho_t2) | C++17 | 5 ms | 3032 KB |
#include <bits/stdc++.h> using namespace std; #define int long long #define ll long long #define pii pair <int, int> #define pb push_back #define mp make_pair #define dbg puts("dbg"); #define outp(x) cout << #x << " = " << (x) << endl int n, k, indeksJ, indeksO, indeksI, mini = 1e9; string S; vector <int> J, O, I; void solve(){ cin >> n >> k; cin >> S; for(int i=0; i<S.length(); i++){ if(S[i] == 'J') J.pb(i); else if(S[i] == 'O') O.pb(i); else I.pb(i); } while(indeksJ < J.size() && indeksO < O.size() && indeksI < I.size()){ int awalJ, awalO, awalI; int akhirJ, akhirO, akhirI; if(indeksJ+k-1 >= J.size()) break; awalJ = J[indeksJ]; akhirJ = J[indeksJ+k-1]; while(O[indeksO] < akhirJ) indeksO++; if(indeksO+k-1 >= O.size()) break; awalO = O[indeksO]; akhirO = O[indeksO+k-1]; while(I[indeksI] < akhirO) indeksI++; if(indeksI+k-1 >= I.size()) break; awalI = I[indeksI]; akhirI = I[indeksI+k-1]; int hapus = akhirI - awalJ + 1 - 3*k; mini = min(mini, hapus); indeksJ++; } cout << ((mini != 1e9)?mini:-1) << endl; } int32_t main() { ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); solve(); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 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 | 0 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 | 0 ms | 212 KB | Output is correct |
13 | Correct | 0 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 | 1 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 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 | 0 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 | 0 ms | 212 KB | Output is correct |
13 | Correct | 0 ms | 212 KB | Output is correct |
14 | Correct | 0 ms | 212 KB | Output is correct |
15 | Correct | 0 ms | 340 KB | Output is correct |
16 | Correct | 0 ms | 340 KB | Output is correct |
17 | Correct | 0 ms | 340 KB | Output is correct |
18 | Correct | 0 ms | 340 KB | Output is correct |
19 | Correct | 1 ms | 340 KB | Output is correct |
20 | Correct | 0 ms | 340 KB | Output is correct |
21 | Correct | 0 ms | 340 KB | Output is correct |
22 | Correct | 0 ms | 340 KB | Output is correct |
23 | Correct | 0 ms | 340 KB | Output is correct |
24 | Correct | 0 ms | 340 KB | Output is correct |
25 | Correct | 0 ms | 340 KB | Output is correct |
26 | Correct | 0 ms | 340 KB | Output is correct |
27 | Correct | 0 ms | 340 KB | Output is correct |
28 | Correct | 1 ms | 340 KB | Output is correct |
29 | Correct | 0 ms | 340 KB | Output is correct |
30 | Correct | 0 ms | 340 KB | Output is correct |
31 | Correct | 1 ms | 340 KB | Output is correct |
32 | Correct | 0 ms | 340 KB | Output is correct |
33 | Correct | 0 ms | 340 KB | Output is correct |
34 | Correct | 0 ms | 340 KB | Output is correct |
35 | Correct | 0 ms | 340 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 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 | 0 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 | 0 ms | 212 KB | Output is correct |
13 | Correct | 0 ms | 212 KB | Output is correct |
14 | Correct | 0 ms | 212 KB | Output is correct |
15 | Correct | 0 ms | 340 KB | Output is correct |
16 | Correct | 0 ms | 340 KB | Output is correct |
17 | Correct | 0 ms | 340 KB | Output is correct |
18 | Correct | 0 ms | 340 KB | Output is correct |
19 | Correct | 1 ms | 340 KB | Output is correct |
20 | Correct | 0 ms | 340 KB | Output is correct |
21 | Correct | 0 ms | 340 KB | Output is correct |
22 | Correct | 0 ms | 340 KB | Output is correct |
23 | Correct | 0 ms | 340 KB | Output is correct |
24 | Correct | 0 ms | 340 KB | Output is correct |
25 | Correct | 0 ms | 340 KB | Output is correct |
26 | Correct | 0 ms | 340 KB | Output is correct |
27 | Correct | 0 ms | 340 KB | Output is correct |
28 | Correct | 1 ms | 340 KB | Output is correct |
29 | Correct | 0 ms | 340 KB | Output is correct |
30 | Correct | 0 ms | 340 KB | Output is correct |
31 | Correct | 1 ms | 340 KB | Output is correct |
32 | Correct | 0 ms | 340 KB | Output is correct |
33 | Correct | 0 ms | 340 KB | Output is correct |
34 | Correct | 0 ms | 340 KB | Output is correct |
35 | Correct | 0 ms | 340 KB | Output is correct |
36 | Correct | 4 ms | 2116 KB | Output is correct |
37 | Correct | 4 ms | 2636 KB | Output is correct |
38 | Correct | 5 ms | 2732 KB | Output is correct |
39 | Correct | 4 ms | 2720 KB | Output is correct |
40 | Correct | 3 ms | 2764 KB | Output is correct |
41 | Correct | 4 ms | 2764 KB | Output is correct |
42 | Correct | 4 ms | 2636 KB | Output is correct |
43 | Correct | 2 ms | 1704 KB | Output is correct |
44 | Correct | 3 ms | 1872 KB | Output is correct |
45 | Correct | 3 ms | 2704 KB | Output is correct |
46 | Correct | 3 ms | 2704 KB | Output is correct |
47 | Correct | 3 ms | 2764 KB | Output is correct |
48 | Correct | 3 ms | 2736 KB | Output is correct |
49 | Correct | 3 ms | 1740 KB | Output is correct |
50 | Correct | 5 ms | 2736 KB | Output is correct |
51 | Correct | 4 ms | 2832 KB | Output is correct |
52 | Correct | 4 ms | 2240 KB | Output is correct |
53 | Correct | 3 ms | 2632 KB | Output is correct |
54 | Correct | 3 ms | 3032 KB | Output is correct |
55 | Correct | 2 ms | 3032 KB | Output is correct |
56 | Correct | 2 ms | 3032 KB | Output is correct |