# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
502650 | banterbry | Job Scheduling (CEOI12_jobs) | C++17 | 308 ms | 31208 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.
#undef _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long
#define pb push_back
#define fi first
#define si second
#define ar array
typedef pair<int,int> pi;
typedef tuple<int,int,int> ti;
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {cerr << " " << to_string(H);debug_out(T...);}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
int N, M, D;
pi req[1000010];
vector<int> ans[100010];
int good(int x) {
for (int i = 1; i <= N; ++i) ans[i].clear();
int j = 1;
for (int i = 1; i <= N; ++i) {
for (int k = 0; k < x; ++k) {
if (req[j].fi > i) break;
if (req[j].fi + D >= i) ans[i].pb(req[j++].si);
else return 0;
if (j == M + 1) return 1;
}
}
return 0;
}
int32_t main() {
fast;
cin >> N >> D >> M;
for (int i = 1; i <= M; ++i) {
cin >> req[i].fi;
req[i].si = i;
}
sort(req + 1, req + 1 + M);
int lo = 0, hi = 1e9;
while (lo + 1 < hi) {
int mid = (lo + hi) / 2;
if (good(mid)) hi = mid;
else lo = mid;
}
cout << hi << '\n';
good(hi);
for (int i = 1; i <= N; ++i) {
for (auto j: ans[i]) cout << j << ' ';
cout << 0 << '\n';
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |