# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
532593 | GioChkhaidze | Job Scheduling (CEOI12_jobs) | C++17 | 248 ms | 16168 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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");
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |