# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
507533 | maco1503 | JJOOII 2 (JOI20_ho_t2) | C++14 | 7 ms | 5488 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define rpd ios_base :: sync_with_stdio(0); cin.tie(0);
#define ll long long
#define fs first
#define sc second
#define pb push_back
#define mod 666013
#define NMAX 100000 + 5
#define inf LLONG_MAX
using namespace std;
ll n,k,mat[4][200005];
int main()
{
rpd;
cin>>n>>k;
string s;
cin>>s;
for(ll i=0;i<s.size();i++)
{
mat[0][i+1]=mat[0][i];
mat[1][i+1]=mat[1][i];
mat[2][i+1]=mat[2][i];
if(s[i]=='J'){
mat[0][i+1]++;
}else if(s[i]=='O'){
mat[1][i+1]++;
}else {
mat[2][i+1]++;
}
}
// for(int i=0;i<=2;i++,cout<<'\n')
// for(int j=1;j<=n;j++)cout<<mat[i][j]<<' ';
ll i=1,j=1,ans=inf,pos=1;
for(ll l=1;l<=n;l++)
{
while(i<=n&&mat[0][i]-mat[0][l-1]<k){
i++;
}
while(j<=n&&mat[1][j]-mat[1][i-1]<k){
j++;
}
while(pos<=n&&mat[2][pos]-mat[2][j-1]<k){
pos++;
}
if(i<=n&&j<=n&&pos<=n){
ans=min(ans,pos-l+1);
}
}
if(ans==inf){
ans=3*k-1;
}
ans-=3*k;
cout<<ans<<'\n';
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... |