# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
763752 | Petrix | Job Scheduling (CEOI12_jobs) | C++17 | 281 ms | 13968 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <algorithm>
using namespace std;
struct vc{
int a,ind;
}v[1000000];
bool cmp(vc a,vc b){
if(a.a<b.a)
return 1;
else
return 0;
}
int n,m;
bool verf(int mij,int d,int n,int m){
int z,i,rasp,stg,j,poz;
i=stg=1;poz=0;
///printf("%d \n",v[2].a);
while(i<=n && stg && poz<m){///printf("a");
for(j=0;j<mij&& poz<m;j++){
//printf("%d ",poz);
if(v[poz].a>i){//printf("| %d %d |",v[poz].a,i);
break;
}else if(v[poz].a+d<i && poz<m){
//printf("{%d %d} ",v[poz].a+d,i);
stg=0;
break;
}else{
poz++;
}
}
i++;
}
//printf("mij: %d | i (<=n) : %d | poz (==m) : %d | stg(==1) : %d\n",mij,i,poz,stg);
if(i<=n && poz==m && stg==1)
return 1;
else
return 0;
}
int main()
{
int st,dr,mij,d,rasp,i,vf,j, stg,poz;
cin>>n>>d>>m;
for(i=0;i<m;i++){
cin>>v[i].a;
v[i].ind=i+1;
}
sort(v,v+m,cmp);
st=1;dr=m/d+1;rasp=mij=0;
while(st<dr){
mij=(st+dr)/2;
vf=verf(mij,d,n,m);
if(vf==1){
rasp=mij;
dr=mij-1;
}else{
st=mij+1;
}
}
cout<<rasp<<"\n";
mij=rasp;
i=stg=1;poz=0;
while(i<=n && stg ){///printf("a");
for(j=0;j<mij;j++){
if(v[poz].a>i)
break;
else{
printf("%d ",v[poz].ind);
poz++;
}
}
printf("0\n");
i++;
}
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |