# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
529166 | ToroTN | Martian DNA (BOI18_dna) | C++14 | 48 ms | 3392 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
int n,m,t,want[15],num1,num2,a[200005],st,md,ed,hsh[15],cnt,type;
int main()
{
scanf("%d%d%d",&n,&m,&t);
for(int i=1;i<=n;i++)
{
scanf("%d",&a[i]);
a[i]+=1;
}
while(t--)
{
scanf("%d%d",&num1,&num2);
want[num1+1]=max(want[num1+1],num2);
}
st=1;
ed=n;
while(ed>=st)
{
type=-1;
md=(st+ed)/2;
//printf("%d %d %d\n",st,md,ed);
memset(hsh,0,sizeof hsh);
for(int i=1;i<=md;i++)
{
++hsh[a[i]];
}
cnt=0;
for(int j=1;j<=m;j++)
{
if(hsh[j]>=want[j])
{
++cnt;
}
}
/*for(int j=1;j<=m;j++)
{
printf("%d ",hsh[j]);
}
printf("\n");*/
if(cnt==m)
{
type=0;
}
for(int i=2;i<=n-md+1;i++)
{
--hsh[a[i-1]];
++hsh[a[i+md-1]];
/*for(int j=1;j<=m;j++)
{
printf("%d ",hsh[j]);
}
printf("\n");*/
cnt=0;
for(int j=1;j<=m;j++)
{
if(hsh[j]>=want[j])
{
++cnt;
}
}
if(cnt==m)
{
type=0;
}
}
if(type==0)
{
ed=md-1;
}else
{
st=md+1;
}
}
if(st==n+1)
{
printf("impossible\n");
}else
{
printf("%d\n",st);
}
}
컴파일 시 표준 에러 (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... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |