# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
206695 |
2020-03-04T15:08:45 Z |
Saboon |
JJOOII 2 (JOI20_ho_t2) |
C++14 |
|
58 ms |
3204 KB |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
const int maxn = 4e5 + 10;
int n, k;
int J[maxn], O[maxn], I[maxn];
int nex(int t, int par[]){
int lo = t - 1, hi = n;
while (hi - lo > 1){
int mid = (lo + hi) >> 1;
if (par[mid + 1] - par[t] >= k)
hi = mid;
else
lo = mid;
}
return hi;
}
int main(){
ios_base::sync_with_stdio(false);
string s;
cin >> n >> k;
cin >> s;
for (int i = 0; i < n; i++){
J[i + 1] = J[i] + (s[i] == 'J');
O[i + 1] = O[i] + (s[i] == 'O');
I[i + 1] = I[i] + (s[i] == 'I');
}
int answer = -1;
for (int i = 0; i < n; i++){
int t = nex(i, J);
t = nex(t, O);
t = nex(t, I);
if (t >= n)
break;
if (answer == -1 or answer > (t - i + 1 - 3 * k))
answer = t - i + 1 - 3 * k;
}
cout << answer << '\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
376 KB |
Output is correct |
3 |
Correct |
5 ms |
376 KB |
Output is correct |
4 |
Correct |
5 ms |
376 KB |
Output is correct |
5 |
Correct |
5 ms |
376 KB |
Output is correct |
6 |
Correct |
5 ms |
376 KB |
Output is correct |
7 |
Correct |
5 ms |
376 KB |
Output is correct |
8 |
Correct |
5 ms |
376 KB |
Output is correct |
9 |
Correct |
5 ms |
376 KB |
Output is correct |
10 |
Correct |
5 ms |
376 KB |
Output is correct |
11 |
Correct |
5 ms |
376 KB |
Output is correct |
12 |
Correct |
5 ms |
376 KB |
Output is correct |
13 |
Correct |
5 ms |
376 KB |
Output is correct |
14 |
Correct |
5 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
376 KB |
Output is correct |
3 |
Correct |
5 ms |
376 KB |
Output is correct |
4 |
Correct |
5 ms |
376 KB |
Output is correct |
5 |
Correct |
5 ms |
376 KB |
Output is correct |
6 |
Correct |
5 ms |
376 KB |
Output is correct |
7 |
Correct |
5 ms |
376 KB |
Output is correct |
8 |
Correct |
5 ms |
376 KB |
Output is correct |
9 |
Correct |
5 ms |
376 KB |
Output is correct |
10 |
Correct |
5 ms |
376 KB |
Output is correct |
11 |
Correct |
5 ms |
376 KB |
Output is correct |
12 |
Correct |
5 ms |
376 KB |
Output is correct |
13 |
Correct |
5 ms |
376 KB |
Output is correct |
14 |
Correct |
5 ms |
376 KB |
Output is correct |
15 |
Correct |
5 ms |
376 KB |
Output is correct |
16 |
Correct |
5 ms |
376 KB |
Output is correct |
17 |
Correct |
5 ms |
376 KB |
Output is correct |
18 |
Correct |
5 ms |
376 KB |
Output is correct |
19 |
Correct |
5 ms |
376 KB |
Output is correct |
20 |
Correct |
5 ms |
376 KB |
Output is correct |
21 |
Correct |
5 ms |
376 KB |
Output is correct |
22 |
Correct |
5 ms |
376 KB |
Output is correct |
23 |
Correct |
5 ms |
376 KB |
Output is correct |
24 |
Correct |
5 ms |
376 KB |
Output is correct |
25 |
Correct |
5 ms |
376 KB |
Output is correct |
26 |
Correct |
5 ms |
376 KB |
Output is correct |
27 |
Correct |
5 ms |
376 KB |
Output is correct |
28 |
Correct |
5 ms |
376 KB |
Output is correct |
29 |
Correct |
5 ms |
376 KB |
Output is correct |
30 |
Correct |
5 ms |
376 KB |
Output is correct |
31 |
Correct |
5 ms |
376 KB |
Output is correct |
32 |
Correct |
5 ms |
376 KB |
Output is correct |
33 |
Correct |
5 ms |
376 KB |
Output is correct |
34 |
Correct |
5 ms |
376 KB |
Output is correct |
35 |
Correct |
5 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
376 KB |
Output is correct |
3 |
Correct |
5 ms |
376 KB |
Output is correct |
4 |
Correct |
5 ms |
376 KB |
Output is correct |
5 |
Correct |
5 ms |
376 KB |
Output is correct |
6 |
Correct |
5 ms |
376 KB |
Output is correct |
7 |
Correct |
5 ms |
376 KB |
Output is correct |
8 |
Correct |
5 ms |
376 KB |
Output is correct |
9 |
Correct |
5 ms |
376 KB |
Output is correct |
10 |
Correct |
5 ms |
376 KB |
Output is correct |
11 |
Correct |
5 ms |
376 KB |
Output is correct |
12 |
Correct |
5 ms |
376 KB |
Output is correct |
13 |
Correct |
5 ms |
376 KB |
Output is correct |
14 |
Correct |
5 ms |
376 KB |
Output is correct |
15 |
Correct |
5 ms |
376 KB |
Output is correct |
16 |
Correct |
5 ms |
376 KB |
Output is correct |
17 |
Correct |
5 ms |
376 KB |
Output is correct |
18 |
Correct |
5 ms |
376 KB |
Output is correct |
19 |
Correct |
5 ms |
376 KB |
Output is correct |
20 |
Correct |
5 ms |
376 KB |
Output is correct |
21 |
Correct |
5 ms |
376 KB |
Output is correct |
22 |
Correct |
5 ms |
376 KB |
Output is correct |
23 |
Correct |
5 ms |
376 KB |
Output is correct |
24 |
Correct |
5 ms |
376 KB |
Output is correct |
25 |
Correct |
5 ms |
376 KB |
Output is correct |
26 |
Correct |
5 ms |
376 KB |
Output is correct |
27 |
Correct |
5 ms |
376 KB |
Output is correct |
28 |
Correct |
5 ms |
376 KB |
Output is correct |
29 |
Correct |
5 ms |
376 KB |
Output is correct |
30 |
Correct |
5 ms |
376 KB |
Output is correct |
31 |
Correct |
5 ms |
376 KB |
Output is correct |
32 |
Correct |
5 ms |
376 KB |
Output is correct |
33 |
Correct |
5 ms |
376 KB |
Output is correct |
34 |
Correct |
5 ms |
376 KB |
Output is correct |
35 |
Correct |
5 ms |
376 KB |
Output is correct |
36 |
Correct |
52 ms |
2820 KB |
Output is correct |
37 |
Correct |
58 ms |
2948 KB |
Output is correct |
38 |
Correct |
55 ms |
3072 KB |
Output is correct |
39 |
Correct |
47 ms |
2948 KB |
Output is correct |
40 |
Correct |
17 ms |
2948 KB |
Output is correct |
41 |
Correct |
38 ms |
2952 KB |
Output is correct |
42 |
Correct |
54 ms |
3076 KB |
Output is correct |
43 |
Correct |
6 ms |
2040 KB |
Output is correct |
44 |
Correct |
6 ms |
2436 KB |
Output is correct |
45 |
Correct |
7 ms |
3076 KB |
Output is correct |
46 |
Correct |
6 ms |
2948 KB |
Output is correct |
47 |
Correct |
7 ms |
3076 KB |
Output is correct |
48 |
Correct |
7 ms |
3076 KB |
Output is correct |
49 |
Correct |
6 ms |
2180 KB |
Output is correct |
50 |
Correct |
7 ms |
3076 KB |
Output is correct |
51 |
Correct |
7 ms |
3076 KB |
Output is correct |
52 |
Correct |
7 ms |
2948 KB |
Output is correct |
53 |
Correct |
7 ms |
3076 KB |
Output is correct |
54 |
Correct |
25 ms |
3204 KB |
Output is correct |
55 |
Correct |
12 ms |
3076 KB |
Output is correct |
56 |
Correct |
7 ms |
3076 KB |
Output is correct |