Submission #1075165

#TimeUsernameProblemLanguageResultExecution timeMemory
1075165inkvizytorJob Scheduling (CEOI12_jobs)C++17
0 / 100
105 ms21180 KiB
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n, d, m; cin >> n >> d >> m; vector<int> v (n+1, 0), sp (n+1, 0); vector<vector<int>> c (n+1); for (int i = 1; i < m+1; i++) { int x; cin >> x; v[x]++; c[x].push_back(i); } vector<int> s; for (auto i : c) { for (int x : i) { s.push_back(x); } } for (int i = 1; i < n+1; i++) { sp[i] = sp[i-1]+v[i]; } int p = 0, j = 1<<20; while (j > 0) { int k = p+j; int wyk = 0; bool b = 1; for (int i = 1; i < n+1; i++) { wyk = min(wyk+k, sp[i]); if (i > d+1 && wyk < sp[i-d-1]) { b = 0; break; } } if (!b) { p += j; } j /= 2; } cout << p+1 << '\n'; int k = p+1, nr = 0; int wyk = 0; for (int i = 1; i < n+1; i++) { wyk = min(wyk+k, sp[i]); while (nr < wyk) { cout << s[nr] << ' '; nr++; } //cout << "0\n"; } }
#Verdict Execution timeMemoryGrader output
Fetching results...