Submission #502646

#TimeUsernameProblemLanguageResultExecution timeMemory
502646banterbryJob Scheduling (CEOI12_jobs)C++17
40 / 100
350 ms61264 KiB
#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) { int cnt = x; while (j <= M && req[j].fi <= i && cnt && req[j].fi - i < D) { ans[i].pb(req[j].si); --cnt; ++j; } } return (j > M); } 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 timeMemoryGrader output
Fetching results...