Submission #1088533

#TimeUsernameProblemLanguageResultExecution timeMemory
1088533vjudge1Job Scheduling (CEOI12_jobs)C++17
100 / 100
113 ms23376 KiB
#include <bits/stdc++.h> using namespace std; using pii = pair<int,int>; const int maxn = 1e5 + 10; int n,d,m; vector<int> v[maxn],resp[maxn]; int main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); cin >> n >> d >> m; for(int i = 1;i <= m;i++){ int x; cin >> x; v[x].push_back(i); } int l = 1,r = m; while(l <= r){ int mid = (l + r) >> 1; bool check = 1; int pos_dia = 1,qtd = 0; for(int i = 1;i <= n && check;i++){ int val = (int) v[i].size(); if(pos_dia < i){ pos_dia = i; qtd = 0; } while(val){ if(pos_dia - i > d){ check = 0; break; } val--; qtd++; if(qtd == mid){ qtd = 0; pos_dia++; } } } if(check) r = mid - 1; else l = mid + 1; } cout << l << "\n"; int pos_dia = 1,qtd = 0; for(int i = 1;i <= n;i++){ if(pos_dia < i){ pos_dia = i; qtd = 0; } while(v[i].size()){ qtd++; resp[pos_dia].push_back(v[i].back()); v[i].pop_back(); if(qtd == l){ qtd = 0; pos_dia++; } } } for(int i = 1;i <= n;i++){ for(int j : resp[i]) cout << j << " "; cout << 0 << "\n"; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...