| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 386097 | strawberry2005 | JJOOII 2 (JOI20_ho_t2) | C++14 | 16 ms | 3312 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int mod = 1e9+7;
#define deb(x) cout<<#x<<": "<<x<<endl
int iceil(int a, int b) {
return (a + b - 1) / b;
}
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.precision(20);
#ifdef strawberryshaker2005
freopen("input.txt", "r", stdin);
#endif
int n,k;
cin>>n>>k;
string s;
cin>>s;
vector<int> J,O,I;
for(int i=0;i<n;i++){
if(s[i]=='J') J.push_back(i);
if(s[i]=='O') O.push_back(i);
if(s[i]=='I') I.push_back(i);
}
int ans=mod;
for(int i=0;i+k-1<J.size();i++){
int start=J[i];
//deb(J[i]);
int end=lower_bound(O.begin(),O.end(),J[i+k-1]+1)-O.begin();
end=end+k-1;
//deb(end);
if(end>=O.size()) continue;
end=O[end];
end=lower_bound(I.begin(),I.end(),end)-I.begin();
end=end+k-1;
if(end>=I.size()) continue;
end=I[end];
ans=min(ans,end-start+1);
}
if(ans==mod) cout<<"-1\n";
else cout<<ans-3*k<<endl;
return(0);
}컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
