제출 #502615

#제출 시각아이디문제언어결과실행 시간메모리
502615banterbryJob Scheduling (CEOI12_jobs)C++17
55 / 100
244 ms31124 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) { int day = 1, cnt = 0; for (int i = 1; i <= M; ++i) { ++cnt; if (cnt > x) { cnt = 1; ++day; } if (day - req[i].fi > D) return 0; if (day > N) return 0; } return 1; } 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'; int day = 1, cnt = 0; for (int i = 1; i <= M; ++i) { ++cnt; if (cnt > hi) { cnt = 1; ++day; } ans[day].pb(req[i].si); } 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...