# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
988487 | hansenhe | Job Scheduling (CEOI12_jobs) | C++14 | 7 ms | 5424 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 int long long
int n, d, m;
pair<int, int> req[100];
vector<vector<int>> out;
bool good(int mach){
vector<vector<int>> each(n + 1);
vector<int> day(mach + 1);
int cur = 1;
for (int i = 0; i < m; i++){
day[cur] = max(day[cur] + 1, req[i].first);
each[day[cur]].push_back(req[i].second);
if (day[cur] - req[i].first > d){
return false;
}
cur++;
cur %= mach;
if (cur == 0) cur = mach;
}
out = each;
return true;
}
signed main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
// freopen("split.in", "r", stdin);
// freopen("split.out", "w", stdout);
cin >> n >> d >> m;
for (int i = 0; i < m; i++){
cin >> req[i].first;
req[i].second = i + 1;
}
sort(req, req + m);
int a = 1, b = m;
while (a != b){
int mid = (a + b) / 2;
if (good(mid)){
b = mid;
} else {
a = mid + 1;
}
}
cout << a << "\n";
for (int i = 1; i <= n; i++){
for (int x : out[i]){
cout << x << " ";
}
cout << "0\n";
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |