# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
230633 | 2020-05-10T16:33:30 Z | AlexLuchianov | JJOOII 2 (JOI20_ho_t2) | C++14 | 29 ms | 1916 KB |
#include <iostream> #include <vector> #include <algorithm> #include <cassert> #include <cmath> #include <set> using namespace std; using ll = long long; int const nmax = 200000; char s[5 + nmax]; vector<int> sets[3]; int lowerthan(vector<int> &v, int target){ int x = 0; for(int jump = (1 << 20); 0 < jump; jump /= 2) if(x + jump < v.size() && v[x + jump] <= target) x += jump; return x; } int eval(int n, int k, int stop){ int init = stop; for(int h = 2; 0 <= h; h--){ int pos = lowerthan(sets[h], stop); if(pos < k) return nmax * 2; stop = sets[h][pos - k + 1] - 1; } return n - 3 * k - (n - init) - stop; } int main() { ios::sync_with_stdio(0); cin.tie(0); int n, k; cin >> n >> k; sets[0].push_back(0); sets[1].push_back(0); sets[2].push_back(0); for(int i = 1; i <= n; i++) { char ch; cin >> ch; if(ch == 'J') sets[0].push_back(i); else if(ch == 'O') sets[1].push_back(i); else sets[2].push_back(i); } int result = nmax * 2; for(int i = 1; i < sets[2].size(); i++) result = min(result, eval(n, k, sets[2][i])); if(result < nmax * 2) cout << result; else cout << -1; return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Correct | 4 ms | 384 KB | Output is correct |
3 | Correct | 4 ms | 384 KB | Output is correct |
4 | Correct | 5 ms | 384 KB | Output is correct |
5 | Correct | 5 ms | 384 KB | Output is correct |
6 | Correct | 5 ms | 384 KB | Output is correct |
7 | Correct | 4 ms | 384 KB | Output is correct |
8 | Correct | 4 ms | 384 KB | Output is correct |
9 | Correct | 4 ms | 384 KB | Output is correct |
10 | Correct | 4 ms | 384 KB | Output is correct |
11 | Correct | 4 ms | 384 KB | Output is correct |
12 | Correct | 4 ms | 384 KB | Output is correct |
13 | Correct | 4 ms | 384 KB | Output is correct |
14 | Correct | 5 ms | 384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Correct | 4 ms | 384 KB | Output is correct |
3 | Correct | 4 ms | 384 KB | Output is correct |
4 | Correct | 5 ms | 384 KB | Output is correct |
5 | Correct | 5 ms | 384 KB | Output is correct |
6 | Correct | 5 ms | 384 KB | Output is correct |
7 | Correct | 4 ms | 384 KB | Output is correct |
8 | Correct | 4 ms | 384 KB | Output is correct |
9 | Correct | 4 ms | 384 KB | Output is correct |
10 | Correct | 4 ms | 384 KB | Output is correct |
11 | Correct | 4 ms | 384 KB | Output is correct |
12 | Correct | 4 ms | 384 KB | Output is correct |
13 | Correct | 4 ms | 384 KB | Output is correct |
14 | Correct | 5 ms | 384 KB | Output is correct |
15 | Correct | 5 ms | 384 KB | Output is correct |
16 | Correct | 5 ms | 384 KB | Output is correct |
17 | Correct | 5 ms | 384 KB | Output is correct |
18 | Correct | 5 ms | 384 KB | Output is correct |
19 | Correct | 5 ms | 384 KB | Output is correct |
20 | Correct | 5 ms | 384 KB | Output is correct |
21 | Correct | 5 ms | 384 KB | Output is correct |
22 | Correct | 5 ms | 384 KB | Output is correct |
23 | Correct | 5 ms | 384 KB | Output is correct |
24 | Correct | 5 ms | 384 KB | Output is correct |
25 | Correct | 5 ms | 384 KB | Output is correct |
26 | Correct | 5 ms | 384 KB | Output is correct |
27 | Correct | 5 ms | 384 KB | Output is correct |
28 | Correct | 5 ms | 384 KB | Output is correct |
29 | Correct | 5 ms | 384 KB | Output is correct |
30 | Correct | 5 ms | 384 KB | Output is correct |
31 | Correct | 5 ms | 384 KB | Output is correct |
32 | Correct | 5 ms | 384 KB | Output is correct |
33 | Correct | 5 ms | 384 KB | Output is correct |
34 | Correct | 5 ms | 384 KB | Output is correct |
35 | Correct | 5 ms | 384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Correct | 4 ms | 384 KB | Output is correct |
3 | Correct | 4 ms | 384 KB | Output is correct |
4 | Correct | 5 ms | 384 KB | Output is correct |
5 | Correct | 5 ms | 384 KB | Output is correct |
6 | Correct | 5 ms | 384 KB | Output is correct |
7 | Correct | 4 ms | 384 KB | Output is correct |
8 | Correct | 4 ms | 384 KB | Output is correct |
9 | Correct | 4 ms | 384 KB | Output is correct |
10 | Correct | 4 ms | 384 KB | Output is correct |
11 | Correct | 4 ms | 384 KB | Output is correct |
12 | Correct | 4 ms | 384 KB | Output is correct |
13 | Correct | 4 ms | 384 KB | Output is correct |
14 | Correct | 5 ms | 384 KB | Output is correct |
15 | Correct | 5 ms | 384 KB | Output is correct |
16 | Correct | 5 ms | 384 KB | Output is correct |
17 | Correct | 5 ms | 384 KB | Output is correct |
18 | Correct | 5 ms | 384 KB | Output is correct |
19 | Correct | 5 ms | 384 KB | Output is correct |
20 | Correct | 5 ms | 384 KB | Output is correct |
21 | Correct | 5 ms | 384 KB | Output is correct |
22 | Correct | 5 ms | 384 KB | Output is correct |
23 | Correct | 5 ms | 384 KB | Output is correct |
24 | Correct | 5 ms | 384 KB | Output is correct |
25 | Correct | 5 ms | 384 KB | Output is correct |
26 | Correct | 5 ms | 384 KB | Output is correct |
27 | Correct | 5 ms | 384 KB | Output is correct |
28 | Correct | 5 ms | 384 KB | Output is correct |
29 | Correct | 5 ms | 384 KB | Output is correct |
30 | Correct | 5 ms | 384 KB | Output is correct |
31 | Correct | 5 ms | 384 KB | Output is correct |
32 | Correct | 5 ms | 384 KB | Output is correct |
33 | Correct | 5 ms | 384 KB | Output is correct |
34 | Correct | 5 ms | 384 KB | Output is correct |
35 | Correct | 5 ms | 384 KB | Output is correct |
36 | Correct | 27 ms | 1400 KB | Output is correct |
37 | Correct | 29 ms | 1656 KB | Output is correct |
38 | Correct | 28 ms | 1768 KB | Output is correct |
39 | Correct | 26 ms | 1784 KB | Output is correct |
40 | Correct | 23 ms | 1752 KB | Output is correct |
41 | Correct | 26 ms | 1784 KB | Output is correct |
42 | Correct | 29 ms | 1656 KB | Output is correct |
43 | Correct | 15 ms | 1272 KB | Output is correct |
44 | Correct | 17 ms | 1384 KB | Output is correct |
45 | Correct | 22 ms | 1784 KB | Output is correct |
46 | Correct | 23 ms | 1656 KB | Output is correct |
47 | Correct | 22 ms | 1912 KB | Output is correct |
48 | Correct | 22 ms | 1656 KB | Output is correct |
49 | Correct | 15 ms | 1152 KB | Output is correct |
50 | Correct | 22 ms | 1752 KB | Output is correct |
51 | Correct | 21 ms | 1784 KB | Output is correct |
52 | Correct | 14 ms | 1464 KB | Output is correct |
53 | Correct | 16 ms | 1648 KB | Output is correct |
54 | Correct | 19 ms | 1788 KB | Output is correct |
55 | Correct | 14 ms | 1788 KB | Output is correct |
56 | Correct | 12 ms | 1916 KB | Output is correct |