이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |