Submission #1075140

#TimeUsernameProblemLanguageResultExecution timeMemory
1075140inkvizytorJob Scheduling (CEOI12_jobs)C++17
20 / 100
104 ms21436 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); } } int sum = 0; 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"; } }

Compilation message (stderr)

jobs.cpp: In function 'int main()':
jobs.cpp:23:9: warning: unused variable 'sum' [-Wunused-variable]
   23 |     int sum = 0;
      |         ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...