Submission #489117

#TimeUsernameProblemLanguageResultExecution timeMemory
489117ak2006Job Scheduling (CEOI12_jobs)C++14
25 / 100
696 ms65540 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; using vb = vector<bool>; using vvb = vector<vb>; using vi = vector<int>; using vvi = vector<vi>; using vl = vector<ll>; using vvl = vector<vl>; using vc = vector<char>; using vvc = vector<vc>; using vs = vector<string>; const ll mod = 1e9 + 7,inf = 1e18; #define pb push_back #define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); void setIO() { fast; } int main() { setIO(); int t,d,m; cin>>t>>d>>m; vvi jobs(m,vi(2)); for (int i = 0;i<m;i++)cin>>jobs[i][0],jobs[i][1] = i + 1; sort(jobs.begin(),jobs.end()); int l = 1,r = t,ans = 1; vvi out; while (l <= r){ int mid = (l + r)/2; bool is = true; int pos = 0,day = 1; vvi cur; while (day <= t){ cur.pb({}); for (int mach = 0;mach < mid;mach++){ if (pos == m)break; if (jobs[pos][0] + d < day){ is = false; break; } cur[(int)cur.size() - 1].pb(jobs[pos][1]); pos++; } if (!is)break; day++; } if (is){ ans = mid; r = mid - 1; out = cur; } else l = mid + 1; } cout<<ans<<endl; for (auto it:out){ for (auto it2:it)cout<<it2<<" "; cout<<0<<endl; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...