# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1094066 | Sunbae | Job Scheduling (CEOI12_jobs) | C++17 | 235 ms | 65536 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;
vector<int> v[100000];
int a[1000000];
vector<int> b[1000000];
signed main(){
int n, d, m; scanf("%d %d %d", &n, &d, &m);
for(int i = 0; i<m; ++i) scanf("%d", a+i), v[--a[i]].push_back(i);
sort(a, a+m);
int low = 1, high = m, ans;
while(low <= high){
int mid = low + ((high-low)>>1), ch = 1;
for(int i = 0; i<m; ++i) b[i/mid].push_back(a[i]);
for(int j = 0; j<=(m-1)/mid; ++j){
for(int x: b[j]) if(ch && j > x + d){ ch = 0; break;}
b[j].clear();
}
if(ch) high = mid-1, ans = mid;
else low = mid+1;
}
for(int i = 0; i<m; ++i) b[i/ans].push_back(a[i]);
for(int j = 0; j<n; ++j){
for(int x: b[j]) printf("%d ", v[x].back() + 1), v[x].pop_back();
printf("0\n");
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |