Submission #745505

#TimeUsernameProblemLanguageResultExecution timeMemory
745505NafeeszxJob Scheduling (CEOI12_jobs)C++14
100 / 100
143 ms23756 KiB
#pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #include <bits/stdc++.h> using namespace std; #define trav(a, x) for(auto& a : x) #define FOR(i, a, b) for (int i=(a); i<=(signed)(b); i++) #define ROF(i, a, b) for (int i=(a); i>=(signed)(b); i--) #define F0R(i, a) for (int i=0; i<(signed)(a); i++) #define vi vector<int> #define f first #define s second #define all(v) (v).begin(), (v).end() typedef long long ll; const int mod = 1e9 + 7, MOD = 998244353; const int N = 2005; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n, m, d; cin >> n >> d >> m; vector<int> v(m); vector<vector<int>> tind(n-d+1); F0R(i, m) { cin >> v[i]; tind[v[i]].push_back(i); } int hi = m, lo = 0; while(hi - lo > 1) { int mid = (hi+lo)/2; bool ok = true; int c = 0; FOR(i, 1, n-d) { if(c + (int)tind[i].size() > mid * (d+1)) { ok = false; break; } c = max(0, c+(int)tind[i].size()-mid); } //cout << mid << '\n'; if(ok) hi=mid; else lo=mid; } cout << hi << '\n'; int day = 1; int mach = 0; vector<vector<int>> res(n+1); FOR(i, 1, n-d) { trav(u, tind[i]) { res[day].push_back(u); mach++; if(mach%hi==0) { mach = 0; day++; } } if(day==i) { day++; mach=0; } } FOR(i, 1, n) { trav(v, res[i]) cout << v+1 << ' '; cout << "0\n"; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...