Submission #892715

#TimeUsernameProblemLanguageResultExecution timeMemory
892715bashNewbieJob Scheduling (CEOI12_jobs)C++17
55 / 100
209 ms29640 KiB
#include <iostream> #include <vector> #include <algorithm> using namespace std; #define fast_io ios::sync_with_stdio(0), cin.tie(0) #define pb push_back template <typename T> using vt = vector<T>; using vi = vt<int>; using vvi = vt<vi>; int main() { fast_io; int n, d, m; cin >> n >> d >> m; vi cnt(n), job(m); vvi in(n); for(int j = 0; j < m; j++) { int x; cin >> x, --x; cnt[x]++, job[j] = x, in[x].pb(j); } vi ord; for(int i = 0; i < n; i++) for(int x: in[i]) ord.pb(x); vvi day; auto proc = [&] (int N) { day = vvi(n); int cur = 0, l = 0; while(l < m) { int f = N; while(l < m && f > 0) { int on = job[ord[l]]; if(on < cur-d) return 0; day[cur].pb(ord[l]), ++l, --f; } ++cur; } return 1; }; int x = 0, y = m, z; while(x < y) { z = x+y >> 1; if(proc(z)) y = z; else x = z+1; } proc(x); cout << x << "\n"; for(int i = 0; i < n; i++) { for(int x: day[i]) cout << x+1 << " "; cout << "0\n"; } }

Compilation message (stderr)

jobs.cpp: In function 'int main()':
jobs.cpp:42:8: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   42 |   z = x+y >> 1;
      |       ~^~
#Verdict Execution timeMemoryGrader output
Fetching results...