# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
224423 | MKopchev | Job Scheduling (CEOI12_jobs) | C++14 | 357 ms | 17144 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
const int MX=1e6+42;
int n,d,m;
pair<int,int> inp[MX];
bool can(int sz)
{
int pos=1;
for(int day=1;day<=n&&pos<=m;day++)
{
if(inp[pos].first+d<day)return 0;
int pos_help=pos;
while(pos_help<=m&&pos_help-pos<sz&&inp[pos_help].first<=day)
{
pos_help++;
}
pos=pos_help;
}
return pos>m;
}
int main()
{
scanf("%i%i%i",&n,&d,&m);
for(int i=1;i<=m;i++)
{
scanf("%i",&inp[i].first);
inp[i].second=i;
}
sort(inp+1,inp+m+1);
int ok=m,not_ok=0;
while(ok-not_ok>1)
{
int av=(ok+not_ok)/2;
if(can(av))ok=av;
else not_ok=av;
}
printf("%i\n",ok);
int pos=1;
for(int day=1;day<=n;day++)
{
int pos_help=pos;
while(pos_help<=m&&pos_help-pos<ok&&inp[pos_help].first<=day)
{
printf("%i ",inp[pos_help].second);
pos_help++;
}
pos=pos_help;
printf("0\n");
}
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |