Submission #988490

#TimeUsernameProblemLanguageResultExecution timeMemory
988490hansenheJob Scheduling (CEOI12_jobs)C++14
80 / 100
340 ms42856 KiB
#include <bits/stdc++.h> using namespace std; #define int long long int n, d, m; pair<int, int> req[1000005]; vector<vector<int>> out; bool good(int mach){ vector<vector<int>> each(n + 1); vector<int> day(mach + 1); int cur = 1; for (int i = 0; i < m; i++){ day[cur] = max(day[cur] + 1, req[i].first); each[day[cur]].push_back(req[i].second); if (day[cur] - req[i].first > d){ return false; } cur++; cur %= mach; if (cur == 0) cur = mach; } out = each; return true; } signed main(){ ios::sync_with_stdio(false); cin.tie(nullptr); // freopen("split.in", "r", stdin); // freopen("split.out", "w", stdout); cin >> n >> d >> m; for (int i = 0; i < m; i++){ cin >> req[i].first; req[i].second = i + 1; } sort(req, req + m); int a = 1, b = m; while (a != b){ int mid = (a + b) / 2; if (good(mid)){ b = mid; } else { a = mid + 1; } } cout << a << "\n"; for (int i = 1; i <= n; i++){ for (int x : out[i]){ cout << x << " "; } cout << "0\n"; } }
#Verdict Execution timeMemoryGrader output
Fetching results...