# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
775747 | NK_ | Job Scheduling (CEOI12_jobs) | C++17 | 132 ms | 26896 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.
// Success consists of going from failure to failure without loss of enthusiasm
#include <bits/stdc++.h>
using namespace std;
#define nl '\n'
#define pb push_back
#define sz(x) int(x.size())
template<class T> using V = vector<T>;
const int nax = 1e6+6;
pair<int, int> in[nax];
int main() {
cin.tie(0)->sync_with_stdio(0);
int N, D, M; cin >> N >> D >> M;
V<V<int>> C(N); for(int i = 0; i < M; i++) {
int t; cin >> t; --t;
C[t].pb(i);
}
V<V<int>> ans(N);
auto check = [&](int x, bool CREATE = 0) -> bool {
int cur = 0, len = 0;
for(int i = 0; i < N; i++) {
if (cur < len && in[cur].first <= i) return 0;
int end = i + D + 1;
for(auto& c : C[i]) in[len++] = {end, c};
int left = x;
while(left-- && cur < len) {
if (CREATE) ans[i].push_back(in[cur].second);
cur++;
}
}
return cur == len;
};
int lo = 0, hi = M + 1;
while(lo < hi) {
int mid = (lo + hi) / 2;
if (check(mid)) hi = mid;
else lo = mid + 1;
}
check(lo, 1);
cout << lo << nl;
for(int i = 0; i < N; i++) {
for(auto x : ans[i]) cout << x + 1 << " ";
cout << 0 << nl;
}
cout << nl;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |