Submission #1000164

#TimeUsernameProblemLanguageResultExecution timeMemory
1000164codexistentJob Scheduling (CEOI12_jobs)C++14
100 / 100
340 ms14160 KiB
#include <bits/stdc++.h> using namespace std; #define FOR(i, a, b) for(int i = a; i <= b; i++) #define MAXN 100005 #define MAXM 1000000 int n, d, m, arr[MAXN]; pair<int, int> req[MAXM]; int main(){ cin >> n >> d >> m; FOR(i, 1, n) arr[i] = 0; FOR(i, 1, m){ int x; cin >> x; arr[x]++; req[i - 1] = {x, i}; } sort(req, req + m); // 4762 multiset<int> s; FOR(i, 1, 1 + d) s.insert(0); int a = 1, b = m; while(a < b){ int mid = (a + b) / 2; bool valid = true; int k = -1; FOR(i, 1, n){ int j = 1; while(j <= mid && (k + 1 < m) && (req[k + 1].first <= i && i <= req[k + 1].first + d)){ j++, k++; } //cout << k + 1 << " " << req[k + 1].first << " ~ " << i << endl; } if(k != m - 1) valid = false; //cout << " YOYO m " << a << " is " << valid << " and we see " << k << endl; if(valid){ b = mid; }else{ a = mid + 1; } } cout << a << endl; int k = -1; FOR(i, 1, n){ int j = 1; while(j <= a && (k + 1 < m) && (req[k + 1].first <= i && i <= req[k + 1].first + d)){ cout << req[k + 1].second << " "; j++, k++; } cout << "0" << endl; } } /* 8 2 12 1 2 4 2 1 3 5 6 2 3 6 4 2 0 8 2 2 2 2 1 2 2 2 */
#Verdict Execution timeMemoryGrader output
Fetching results...