# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
525332 |
2022-02-11T10:54:54 Z |
l3nl3 |
JJOOII 2 (JOI20_ho_t2) |
C++17 |
|
2000 ms |
4456 KB |
//#pragma GCC optimize("O3")
//#pragma GCC target ("avx2")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#define int long long
#define all(a) a.begin(), a.end()
using namespace std;
const int N = 2e5 + 7;
int n, k, mn = 1e18;
string s;
signed main () {
ios_base::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
cin >> n >> k >> s;
s = '~' + s;
for (int i = 0; i <= n; i++) {
int J = 0, O = 0, I = 0, res = 0;
vector<int> aa;
for (int j = i + 1; j <= n; j++) {
if (s[j] == 'J') {
if (J == k) {
res++;
aa.push_back(j);
continue;
}
J++;
}
if (s[j] == 'O') {
if (O == k || J < k) {
res++;
aa.push_back(j);
continue;
}
O++;
}
if (s[j] == 'I') {
if (I == k || O < k || J < k) {
res++;
aa.push_back(j);
continue;
}
I++;
}
}
int l = n, p = aa.size() - 1;
while (p >= 0 && aa[p] == l) {
l--;
p--;
res--;
}
if (J == k && O == k && I == k) mn = min(mn, res);
}
cout << (mn == 1e18 ? -1 : mn);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
312 KB |
Output is correct |
4 |
Correct |
1 ms |
312 KB |
Output is correct |
5 |
Correct |
1 ms |
312 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
312 KB |
Output is correct |
8 |
Correct |
0 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
316 KB |
Output is correct |
10 |
Correct |
1 ms |
204 KB |
Output is correct |
11 |
Correct |
1 ms |
312 KB |
Output is correct |
12 |
Correct |
0 ms |
204 KB |
Output is correct |
13 |
Correct |
0 ms |
204 KB |
Output is correct |
14 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
312 KB |
Output is correct |
4 |
Correct |
1 ms |
312 KB |
Output is correct |
5 |
Correct |
1 ms |
312 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
312 KB |
Output is correct |
8 |
Correct |
0 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
316 KB |
Output is correct |
10 |
Correct |
1 ms |
204 KB |
Output is correct |
11 |
Correct |
1 ms |
312 KB |
Output is correct |
12 |
Correct |
0 ms |
204 KB |
Output is correct |
13 |
Correct |
0 ms |
204 KB |
Output is correct |
14 |
Correct |
1 ms |
204 KB |
Output is correct |
15 |
Correct |
18 ms |
308 KB |
Output is correct |
16 |
Correct |
24 ms |
312 KB |
Output is correct |
17 |
Correct |
31 ms |
372 KB |
Output is correct |
18 |
Correct |
8 ms |
332 KB |
Output is correct |
19 |
Correct |
29 ms |
332 KB |
Output is correct |
20 |
Correct |
24 ms |
332 KB |
Output is correct |
21 |
Correct |
21 ms |
380 KB |
Output is correct |
22 |
Correct |
17 ms |
348 KB |
Output is correct |
23 |
Correct |
6 ms |
312 KB |
Output is correct |
24 |
Correct |
20 ms |
332 KB |
Output is correct |
25 |
Correct |
20 ms |
332 KB |
Output is correct |
26 |
Correct |
20 ms |
352 KB |
Output is correct |
27 |
Correct |
20 ms |
332 KB |
Output is correct |
28 |
Correct |
19 ms |
312 KB |
Output is correct |
29 |
Correct |
23 ms |
336 KB |
Output is correct |
30 |
Correct |
21 ms |
352 KB |
Output is correct |
31 |
Correct |
5 ms |
204 KB |
Output is correct |
32 |
Correct |
26 ms |
332 KB |
Output is correct |
33 |
Correct |
18 ms |
332 KB |
Output is correct |
34 |
Correct |
16 ms |
332 KB |
Output is correct |
35 |
Correct |
17 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
312 KB |
Output is correct |
4 |
Correct |
1 ms |
312 KB |
Output is correct |
5 |
Correct |
1 ms |
312 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
312 KB |
Output is correct |
8 |
Correct |
0 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
316 KB |
Output is correct |
10 |
Correct |
1 ms |
204 KB |
Output is correct |
11 |
Correct |
1 ms |
312 KB |
Output is correct |
12 |
Correct |
0 ms |
204 KB |
Output is correct |
13 |
Correct |
0 ms |
204 KB |
Output is correct |
14 |
Correct |
1 ms |
204 KB |
Output is correct |
15 |
Correct |
18 ms |
308 KB |
Output is correct |
16 |
Correct |
24 ms |
312 KB |
Output is correct |
17 |
Correct |
31 ms |
372 KB |
Output is correct |
18 |
Correct |
8 ms |
332 KB |
Output is correct |
19 |
Correct |
29 ms |
332 KB |
Output is correct |
20 |
Correct |
24 ms |
332 KB |
Output is correct |
21 |
Correct |
21 ms |
380 KB |
Output is correct |
22 |
Correct |
17 ms |
348 KB |
Output is correct |
23 |
Correct |
6 ms |
312 KB |
Output is correct |
24 |
Correct |
20 ms |
332 KB |
Output is correct |
25 |
Correct |
20 ms |
332 KB |
Output is correct |
26 |
Correct |
20 ms |
352 KB |
Output is correct |
27 |
Correct |
20 ms |
332 KB |
Output is correct |
28 |
Correct |
19 ms |
312 KB |
Output is correct |
29 |
Correct |
23 ms |
336 KB |
Output is correct |
30 |
Correct |
21 ms |
352 KB |
Output is correct |
31 |
Correct |
5 ms |
204 KB |
Output is correct |
32 |
Correct |
26 ms |
332 KB |
Output is correct |
33 |
Correct |
18 ms |
332 KB |
Output is correct |
34 |
Correct |
16 ms |
332 KB |
Output is correct |
35 |
Correct |
17 ms |
332 KB |
Output is correct |
36 |
Execution timed out |
2047 ms |
4456 KB |
Time limit exceeded |
37 |
Halted |
0 ms |
0 KB |
- |