# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1023719 |
2024-07-15T05:21:46 Z |
vjudge1 |
JJOOII 2 (JOI20_ho_t2) |
C++17 |
|
2000 ms |
860 KB |
#include "bits/stdc++.h"
#define int long long
using namespace std;
const int mod = 1000000007;
signed main() {
ios_base::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
int n,k;
cin>>n>>k;
string s;
cin>>s;
int mn=1e18;
for(int l=0;l<n;l++){
map<char,int>mp;
for(int r=l;r<n;r++){
if(s[r]=='J'){
mp[s[r]]++;
}
if(s[r]=='O' and mp['J']>=k){
mp[s[r]]++;
}
if(s[r]=='I' and mp['O']>=k){
mp[s[r]]++;
}
if(mp['J']>=k and mp['I']>=k and mp['O']>=k){
mn=min(mn,((r+1)-(l+1)+1)-(3*k));
break;
}
// cout<<l<<" "<<r<<endl;
// cout<<s2<<endl<<endl;
}
}
if(mn==1e18){
cout<<-1;
}else{
cout<<mn;
}
// int t;
// cin>>t;
// while(t--){
// int n, m; cin >> n >> m;
//// f.resize(n + 1), inv.resize(n + 1);
////
//// f[0] = inv[0] = 1;
//// for(int i=1;i<=n;i++){
//// f[i] = f[i - 1] * 1ll * i % mod;
////
//// inv[i] = binary_power(f[i], mod - 2, mod);
//// }
//
// cout<<bin(n,m)<<"\n";
//}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
344 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
344 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
2 ms |
348 KB |
Output is correct |
18 |
Correct |
17 ms |
452 KB |
Output is correct |
19 |
Correct |
9 ms |
348 KB |
Output is correct |
20 |
Correct |
8 ms |
348 KB |
Output is correct |
21 |
Correct |
31 ms |
464 KB |
Output is correct |
22 |
Correct |
30 ms |
348 KB |
Output is correct |
23 |
Correct |
9 ms |
452 KB |
Output is correct |
24 |
Correct |
37 ms |
344 KB |
Output is correct |
25 |
Correct |
36 ms |
348 KB |
Output is correct |
26 |
Correct |
43 ms |
596 KB |
Output is correct |
27 |
Correct |
35 ms |
348 KB |
Output is correct |
28 |
Correct |
33 ms |
348 KB |
Output is correct |
29 |
Correct |
35 ms |
344 KB |
Output is correct |
30 |
Correct |
35 ms |
344 KB |
Output is correct |
31 |
Correct |
6 ms |
348 KB |
Output is correct |
32 |
Correct |
30 ms |
348 KB |
Output is correct |
33 |
Correct |
21 ms |
348 KB |
Output is correct |
34 |
Correct |
22 ms |
348 KB |
Output is correct |
35 |
Correct |
17 ms |
464 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
344 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
2 ms |
348 KB |
Output is correct |
18 |
Correct |
17 ms |
452 KB |
Output is correct |
19 |
Correct |
9 ms |
348 KB |
Output is correct |
20 |
Correct |
8 ms |
348 KB |
Output is correct |
21 |
Correct |
31 ms |
464 KB |
Output is correct |
22 |
Correct |
30 ms |
348 KB |
Output is correct |
23 |
Correct |
9 ms |
452 KB |
Output is correct |
24 |
Correct |
37 ms |
344 KB |
Output is correct |
25 |
Correct |
36 ms |
348 KB |
Output is correct |
26 |
Correct |
43 ms |
596 KB |
Output is correct |
27 |
Correct |
35 ms |
348 KB |
Output is correct |
28 |
Correct |
33 ms |
348 KB |
Output is correct |
29 |
Correct |
35 ms |
344 KB |
Output is correct |
30 |
Correct |
35 ms |
344 KB |
Output is correct |
31 |
Correct |
6 ms |
348 KB |
Output is correct |
32 |
Correct |
30 ms |
348 KB |
Output is correct |
33 |
Correct |
21 ms |
348 KB |
Output is correct |
34 |
Correct |
22 ms |
348 KB |
Output is correct |
35 |
Correct |
17 ms |
464 KB |
Output is correct |
36 |
Correct |
34 ms |
856 KB |
Output is correct |
37 |
Correct |
36 ms |
856 KB |
Output is correct |
38 |
Correct |
36 ms |
860 KB |
Output is correct |
39 |
Execution timed out |
2032 ms |
856 KB |
Time limit exceeded |
40 |
Halted |
0 ms |
0 KB |
- |