답안 #960893

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
960893 2024-04-11T07:51:35 Z AlgorithmWarrior JJOOII 2 (JOI20_ho_t2) C++14
0 / 100
0 ms 444 KB
#include <bits/stdc++.h>
#define MAX 200005

using namespace std;

int vj[MAX],vo[MAX],vi[MAX];

int main()
{
    int n,k;
    cin>>n>>k;
    int i;
    for(i=1;i<=n;++i)
    {
        char ch;
        cin>>ch;
        if(ch=='J')
            vj[++vj[0]]=i;
        if(ch=='O')
            vo[++vo[0]]=i;
        if(ch=='I')
            vi[++vi[0]]=i;
    }
    int pj,po=1,pi=1;
    int ans=1e9;
    for(pj=1;pj<=vj[0];++pj)
    {
        while(po+k-1<=vo[0] && vo[po]<vj[pj+k-1])
            ++po;
        if(po+k-1<=vo[0])
        {
            while(pi+k-1<=vi[0] && vi[pi]<vo[po+k-1])
                ++pi;
            if(pi+k-1<=vi[0])
                ans=min(ans,vi[pi+k-1]-vj[pj]+1-3*k);
        }
    }
    cout<<ans;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 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 444 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 Incorrect 0 ms 348 KB Output isn't correct
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 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 444 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 Incorrect 0 ms 348 KB Output isn't correct
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 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 444 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 Incorrect 0 ms 348 KB Output isn't correct
10 Halted 0 ms 0 KB -