# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
254446 | shrek12357 | Job Scheduling (CEOI12_jobs) | C++14 | 701 ms | 14548 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>
#include <string>
#include <map>
#include <set>
#include <climits>
#include <cmath>
#include <fstream>
#include <queue>
using namespace std;
int main() {
int n, d, m;
cin >> n >> d >> m;
vector<int> nums(n);
vector<pair<int, int>> cows;
for (int i = 0; i < m; i++) {
int temp;
cin >> temp;
temp--;
nums[temp]++;
cows.push_back(make_pair(temp, i + 1));
}
sort(cows.begin(), cows.end());
int lo = 0;
int hi = 1000005;
while (lo < hi) {
int mid = (lo + hi) / 2;
vector<int> temp = nums;
int idx = 0;
bool bad = false;
for (int i = 0; i < n; i++) {
if (idx + d < i && idx != n - d) {
bad = true;
break;
}
int tCounter = mid;
while (idx <= i && tCounter > 0) {
if (idx == n - d) {
break;
}
if (temp[idx] > tCounter) {
temp[idx] -= tCounter;
break;
}
else {
tCounter -= temp[idx];
temp[idx] = 0;
idx++;
}
}
}
if (!bad) {
hi = mid;
}
else {
lo = mid + 1;
}
}
cout << hi << endl;
int counter = 0;
int countDays = 0;
for (int i = 0; i < cows.size(); i++) {
cout << cows[i].second << " ";
counter++;
if (counter == hi) {
cout << 0 << endl;
countDays++;
counter = 0;
}
}
for (int i = 0; i < n - countDays; i++) {
cout << 0 << endl;
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |