# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
254445 | shrek12357 | Job Scheduling (CEOI12_jobs) | C++14 | 393 ms | 6680 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);
map<int, vector<int>> cows;
for (int i = 0; i < m; i++) {
int temp;
cin >> temp;
temp--;
nums[temp]++;
cows[temp].push_back(i + 1);
}
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 ans = 0;
int countDays = 0;
for (int i = 0; i < n; i++) {
for (auto p : cows[i]) {
cout << p << " ";
ans++;
if (ans == hi) {
ans = 0;
cout << 0 << endl;
countDays++;
}
}
}
for (int i = 0; i < n - countDays; i++) {
cout << 0 << endl;
}
*/
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |