# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
253259 |
2020-07-27T14:38:24 Z |
doowey |
JJOOII 2 (JOI20_ho_t2) |
C++14 |
|
14 ms |
1816 KB |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
const int N = (int)2e5 + 10;
vector<int> lis[3];
int main(){
fastIO;
int n, k;
cin >> n >> k;
char f;
int x;
for(int i = 1; i <= n; i ++ ){
cin >> f;
if(f == 'J')
x = 0;
else if(f == 'O')
x = 1;
else
x = 2;
lis[x].push_back(i);
}
int nx;
int pp;
int shi;
int fq;
int en;
int idx;
int ans = (int)1e9;
for(int i = 0 ; i < lis[0].size(); i ++ ){
if(i + k - 1 < lis[0].size()){
nx = lis[0][i + k - 1];
pp = upper_bound(lis[1].begin(), lis[1].end(), nx) - lis[1].begin();
if(pp + k - 1 < lis[1].size()){
shi = lis[1][pp + k - 1];
fq = upper_bound(lis[2].begin(), lis[2].end(), shi) - lis[2].begin();
if(fq + k - 1 < lis[2].size()){
en = lis[2][fq + k - 1];
idx = en - lis[0][i] + 1;
ans = min(ans, idx-3*k);
}
}
}
}
if(ans == (int)1e9)
cout << -1 << "\n";
else
cout << ans << "\n";
return 0;
}
Compilation message
ho_t2.cpp: In function 'int main()':
ho_t2.cpp:39:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i = 0 ; i < lis[0].size(); i ++ ){
~~^~~~~~~~~~~~~~~
ho_t2.cpp:40:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if(i + k - 1 < lis[0].size()){
~~~~~~~~~~^~~~~~~~~~~~~~~
ho_t2.cpp:43:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if(pp + k - 1 < lis[1].size()){
~~~~~~~~~~~^~~~~~~~~~~~~~~
ho_t2.cpp:46:31: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if(fq + k - 1 < lis[2].size()){
~~~~~~~~~~~^~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
0 ms |
384 KB |
Output is correct |
5 |
Correct |
0 ms |
384 KB |
Output is correct |
6 |
Correct |
0 ms |
384 KB |
Output is correct |
7 |
Correct |
0 ms |
384 KB |
Output is correct |
8 |
Correct |
1 ms |
384 KB |
Output is correct |
9 |
Correct |
1 ms |
384 KB |
Output is correct |
10 |
Correct |
0 ms |
384 KB |
Output is correct |
11 |
Correct |
0 ms |
384 KB |
Output is correct |
12 |
Correct |
0 ms |
384 KB |
Output is correct |
13 |
Correct |
1 ms |
384 KB |
Output is correct |
14 |
Correct |
0 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
0 ms |
384 KB |
Output is correct |
5 |
Correct |
0 ms |
384 KB |
Output is correct |
6 |
Correct |
0 ms |
384 KB |
Output is correct |
7 |
Correct |
0 ms |
384 KB |
Output is correct |
8 |
Correct |
1 ms |
384 KB |
Output is correct |
9 |
Correct |
1 ms |
384 KB |
Output is correct |
10 |
Correct |
0 ms |
384 KB |
Output is correct |
11 |
Correct |
0 ms |
384 KB |
Output is correct |
12 |
Correct |
0 ms |
384 KB |
Output is correct |
13 |
Correct |
1 ms |
384 KB |
Output is correct |
14 |
Correct |
0 ms |
384 KB |
Output is correct |
15 |
Correct |
1 ms |
384 KB |
Output is correct |
16 |
Correct |
1 ms |
384 KB |
Output is correct |
17 |
Correct |
1 ms |
384 KB |
Output is correct |
18 |
Correct |
0 ms |
384 KB |
Output is correct |
19 |
Correct |
1 ms |
384 KB |
Output is correct |
20 |
Correct |
1 ms |
384 KB |
Output is correct |
21 |
Correct |
1 ms |
384 KB |
Output is correct |
22 |
Correct |
1 ms |
384 KB |
Output is correct |
23 |
Correct |
1 ms |
384 KB |
Output is correct |
24 |
Correct |
1 ms |
384 KB |
Output is correct |
25 |
Correct |
0 ms |
384 KB |
Output is correct |
26 |
Correct |
0 ms |
384 KB |
Output is correct |
27 |
Correct |
1 ms |
384 KB |
Output is correct |
28 |
Correct |
1 ms |
384 KB |
Output is correct |
29 |
Correct |
1 ms |
384 KB |
Output is correct |
30 |
Correct |
1 ms |
384 KB |
Output is correct |
31 |
Correct |
0 ms |
384 KB |
Output is correct |
32 |
Correct |
1 ms |
384 KB |
Output is correct |
33 |
Correct |
1 ms |
384 KB |
Output is correct |
34 |
Correct |
0 ms |
384 KB |
Output is correct |
35 |
Correct |
0 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
0 ms |
384 KB |
Output is correct |
5 |
Correct |
0 ms |
384 KB |
Output is correct |
6 |
Correct |
0 ms |
384 KB |
Output is correct |
7 |
Correct |
0 ms |
384 KB |
Output is correct |
8 |
Correct |
1 ms |
384 KB |
Output is correct |
9 |
Correct |
1 ms |
384 KB |
Output is correct |
10 |
Correct |
0 ms |
384 KB |
Output is correct |
11 |
Correct |
0 ms |
384 KB |
Output is correct |
12 |
Correct |
0 ms |
384 KB |
Output is correct |
13 |
Correct |
1 ms |
384 KB |
Output is correct |
14 |
Correct |
0 ms |
384 KB |
Output is correct |
15 |
Correct |
1 ms |
384 KB |
Output is correct |
16 |
Correct |
1 ms |
384 KB |
Output is correct |
17 |
Correct |
1 ms |
384 KB |
Output is correct |
18 |
Correct |
0 ms |
384 KB |
Output is correct |
19 |
Correct |
1 ms |
384 KB |
Output is correct |
20 |
Correct |
1 ms |
384 KB |
Output is correct |
21 |
Correct |
1 ms |
384 KB |
Output is correct |
22 |
Correct |
1 ms |
384 KB |
Output is correct |
23 |
Correct |
1 ms |
384 KB |
Output is correct |
24 |
Correct |
1 ms |
384 KB |
Output is correct |
25 |
Correct |
0 ms |
384 KB |
Output is correct |
26 |
Correct |
0 ms |
384 KB |
Output is correct |
27 |
Correct |
1 ms |
384 KB |
Output is correct |
28 |
Correct |
1 ms |
384 KB |
Output is correct |
29 |
Correct |
1 ms |
384 KB |
Output is correct |
30 |
Correct |
1 ms |
384 KB |
Output is correct |
31 |
Correct |
0 ms |
384 KB |
Output is correct |
32 |
Correct |
1 ms |
384 KB |
Output is correct |
33 |
Correct |
1 ms |
384 KB |
Output is correct |
34 |
Correct |
0 ms |
384 KB |
Output is correct |
35 |
Correct |
0 ms |
384 KB |
Output is correct |
36 |
Correct |
12 ms |
1400 KB |
Output is correct |
37 |
Correct |
14 ms |
1656 KB |
Output is correct |
38 |
Correct |
14 ms |
1768 KB |
Output is correct |
39 |
Correct |
13 ms |
1784 KB |
Output is correct |
40 |
Correct |
11 ms |
1752 KB |
Output is correct |
41 |
Correct |
12 ms |
1768 KB |
Output is correct |
42 |
Correct |
13 ms |
1656 KB |
Output is correct |
43 |
Correct |
9 ms |
1272 KB |
Output is correct |
44 |
Correct |
8 ms |
1384 KB |
Output is correct |
45 |
Correct |
11 ms |
1676 KB |
Output is correct |
46 |
Correct |
10 ms |
1656 KB |
Output is correct |
47 |
Correct |
10 ms |
1816 KB |
Output is correct |
48 |
Correct |
10 ms |
1784 KB |
Output is correct |
49 |
Correct |
10 ms |
1152 KB |
Output is correct |
50 |
Correct |
10 ms |
1780 KB |
Output is correct |
51 |
Correct |
10 ms |
1784 KB |
Output is correct |
52 |
Correct |
7 ms |
1628 KB |
Output is correct |
53 |
Correct |
7 ms |
1528 KB |
Output is correct |
54 |
Correct |
7 ms |
1788 KB |
Output is correct |
55 |
Correct |
6 ms |
1788 KB |
Output is correct |
56 |
Correct |
6 ms |
1804 KB |
Output is correct |