# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
66287 | ikura355 | Job Scheduling (CEOI12_jobs) | C++14 | 333 ms | 13868 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>
using namespace std;
#define ll long long
#define pii pair<int,int>
#define X first
#define Y second
const int maxn = 1e6 + 5;
int n,d,m;
pii a[maxn];
bool check(ll num) {
if(num*n < m) return 0;
for(ll day=0;day<n;day++) {
for(ll i=day*num;i<min((ll)m,(day+1)*num);i++) {
if(a[i].X+d<day+1) return 0;
}
}
return 1;
}
int main() {
scanf("%d%d%d",&n,&d,&m);
for(int i=0;i<m;i++) scanf("%d",&a[i].X), a[i].Y = i+1;
sort(&a[0],&a[m]);
int l = 0, r = m, mid, res = -1;
while(l<=r) {
mid = (l+r)/2;
if(check(mid)) {
res = mid;
r = mid-1;
}
else l = mid+1;
}
printf("%d\n",res);
for(ll day=0;day<n;day++) {
for(ll i=day*res;i<min((ll)m,(day+1)*res);i++) {
printf("%d ",a[i].Y);
}
printf("0\n");
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |