# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
554890 | Genius3435 | Job Scheduling (CEOI12_jobs) | C++17 | 286 ms | 13516 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;
constexpr int N = 100005;
constexpr int M = 1000005;
vector<int> ids[N];
int n, d, m;
bool test(int c, bool print=false) {
queue<pair<int, int>> q; // stores {day, id}
for (int i = 1; i <= n; ++i) {
for (const int id : ids[i]) q.emplace(i, id);
for (int j = 0; j < c && !q.empty(); ++j) {
if (print) printf("%d ", q.front().second);
q.pop();
}
if (print) printf("0\n");
if (!q.empty() && q.front().first <= i-d) return false;
}
return q.empty();
}
int main() {
cin.tie(nullptr)->sync_with_stdio(false);
cin >> n >> d >> m;
for (int x, i = 1; i <= m; ++i) {
cin >> x; ids[x].push_back(i);
}
int l = 1, r = m;
while (l < r) {
const int md = l + (r-l)/2;
if (test(md)) r = md;
else l = md+1;
}
printf("%d\n", l);
test(l, true);
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |