# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
219574 | MKopchev | JJOOII 2 (JOI20_ho_t2) | C++14 | 25 ms | 1908 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
const int nmax=2e5+42;
int n,k;
vector<int> seen[3];
int ask(int pos,int where)
{
if(where==3)return pos;
pos++;
int nxt_seen=lower_bound(seen[where].begin(),seen[where].end(),pos)-seen[where].begin();
if(nxt_seen+k-1<seen[where].size())return ask(seen[where][nxt_seen+k-1],where+1);
return 1e9;
}
int main()
{
scanf("%i%i",&n,&k);
for(int i=1;i<=n;i++)
{
char c=getchar();
while(c!='J'&&c!='O'&&c!='I')c=getchar();
if(c=='J')seen[0].push_back(i);
else if(c=='O')seen[1].push_back(i);
else seen[2].push_back(i);
}
int output=n+1;
for(auto start:seen[0])
output=min(output,ask(start-1,0)-start+1-3*k);
if(output>n)printf("-1\n");
else printf("%i\n",output);
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... |