# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
41290 | evpipis | Job Scheduling (CEOI12_jobs) | C++98 | 354 ms | 14692 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 fi first
#define se second
typedef pair<int, int> ii;
const int len = 1e6+5;
int n, d, m;
ii a[len];
bool check(int x){
int po = 0;
for (int i = 1; i <= n+1; i++){
int temp = x;
while (po < m && temp-- && a[po].fi <= i){
if (i > d+a[po].fi) return false;
po++;
}
}
return true;
}
int bs(){
int l = 1, r = m, ans;
while (l <= r){
int mid = (l+r)/2;
if (check(mid)){
ans = mid;
r = mid-1;
}
else
l = mid+1;
}
return ans;
}
int main(){
scanf("%d %d %d", &n, &d, &m);
for (int i = 0; i < m; i++){
scanf("%d", &a[i].fi);
a[i].se = i+1;
}
sort(a, a+m);
int x = bs();
printf("%d\n", x);
int po = 0;
for (int i = 1; i <= n; i++){
int temp = x;
while (po < m && temp-- && a[po].fi <= i){
printf("%d ", a[po].se);
po++;
}
printf("0\n");
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |