# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
557330 | Ai7081 | Job Scheduling (CEOI12_jobs) | C++17 | 221 ms | 14444 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;
const int N = 100005;
int n, m, d, in, sum[N];
vector<int> v[N];
bool run(int x, bool p) {
int now=1, point=0;
if (p) printf("%d\n", x);
for (int i=1; i<=n; i++) {
int cnt = x;
while (now <= i && cnt--) {
if (point >= v[now].size()) {now++, point=0, cnt++; continue;}
if (p) printf("%d ", v[now][point]);
point++;
}
if (p) printf("0\n");
}
return now == n+1;
}
int bs(int l, int r) {
if (l == r) return l;
int mid = (l+r)/2;
if (run(mid, 0)) return bs(l, mid);
return bs(mid+1, r);
}
int main() {
scanf(" %d %d %d", &n, &d, &m);
for (int i=1; i<=m; i++) scanf(" %d", &in), v[in].push_back(i);
for (int i=1; i<=n; i++) sum[i] = sum[i-1] + v[i].size();
run(bs(1, 1000000), 1);
return 0;
}
/*
8 2 12
1 2 4 2 1 3 5 6 2 3 6 4
*/
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |