Submission #1308296

#TimeUsernameProblemLanguageResultExecution timeMemory
1308296joze_plocnikJob Scheduling (CEOI12_jobs)C++20
50 / 100
201 ms13980 KiB
#include <iostream> #include <algorithm> #include <vector> #include <queue> #define vi vector<int> #define vpii vector<pair<int,int>> #define oopt cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(false); #define forn(i,n) for(int i = 0; i<n; i++) #define sz(x) (x).size() using namespace std; int main() { //oopt; int n,d,m; cin >> n >> d>>m; vi naroceni(n); vector<vector<int>> vrednosti(n); // to ti poje malo preveč vsega (že prazen deque = 80 bytov) pair<int,int> pntr = {0,0}; //na katerem id-ju smo, pa kateri po vrsti tam forn(i,m){ int t; cin >> t; naroceni[--t]++; vrednosti[t].push_back(i+1); } int l = 1, r= 1e6; while(l<r){ int rob = (l+r)/2; bool vredu = true; pntr = {0,0}; forn(i,n){ if(!vredu) break; int mesta = rob; while(mesta){ while(pntr.first < n && pntr.second >= vrednosti[pntr.first].size()){ if(i-pntr.first > d) { vredu = false; break; } pntr.first++; pntr.second = 0; } if(!vredu || pntr.first > i) break; pntr.second++; mesta--; } } if(n-pntr.first > d){ vredu = false; } if(vredu){ r = rob; } else { l = rob+1; } } cout << l << "\n"; pntr = {0,0}; forn(i,n){ int mesta = l; while(mesta){ while(pntr.second >= vrednosti[pntr.first].size()){ pntr.first++; pntr.second = 0; if(pntr.first > i) break; } if(pntr.first > i) break; cout << vrednosti[pntr.first][pntr.second] << " "; pntr.second++; mesta--; } cout << "0\n"; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...