# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
623330 | binisgiannis | Job Scheduling (CEOI12_jobs) | C++14 | 305 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 <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef pair<int, int> pi;
#define x first
#define y second
int N, D, M; vector<pi> vec;
vector<vector<int>> f(int x) {
vector<vector<int>> res(N, vector<int>(x, 0));
int index = 0;
for (int i = 0; i < N; i++) {
for (int j = 0; j < x; j++) {
res[i][j] = vec[index].y;
index++;
if (index >= M) goto endofloop;
}
}
endofloop:
if (index < M) return {{-1}};
return res;
}
int main() {
cin >> N >> D >> M;
vec.resize(M);
for (int i = 0; i < M; i++) {
cin >> vec[i].x;
vec[i].y = i+1;
}
sort(vec.begin(), vec.end());
int l = 1, r = M; vector<vector<int>> result;
while (l < r) {
int mid = (l+r)/2;
vector<vector<int>> out = f(mid);
if (out[0][0] == -1) l = mid+1;
else {
r = mid;
result = out;
}
}
for (int i = 0; i < result.size(); i++) {
for (int j = 0; j < result[i].size(); j++) {
if (result[i][0] == 0) break;
cout << result[i][j] << ' ';
}
cout << 0 << '\n';
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |