# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
532593 | GioChkhaidze | Job Scheduling (CEOI12_jobs) | C++17 | 248 ms | 16168 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
const int N=1e6+6;
int n,d,m;
pair < int , int > a[N];
bool check(int x) {
int j=0,X=0;
for (int Days=1; Days<=n; Days++) {
X=x;
while (j+1<=m && X-1>=0 && a[j+1].F<=Days) {
if (Days>a[j+1].F+d) return 0;
X--,j++;
}
}
if (j!=m) return 0;
return 1;
}
main () {
scanf("%d%d%d",&n,&d,&m);
for (int i=1; i<=m; i++) {
scanf("%d",&a[i].F);
a[i].S=i;
}
sort(a+1,a+m+1);
int l=1,r=m,mid,res=-1;
while (l<=r) {
mid=(l+r)/2;
if (check(mid)) r=mid-1,res=mid;
else l=mid+1;
}
printf("%d\n",res);
int j=0,X=0;
for (int Days=1; Days<=n; Days++) {
X=res;
while (j+1<=m && X-1>=0 && a[j+1].F<=Days) {
printf("%d ",a[j+1].S);
X--,j++;
}
printf("0\n");
}
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |