Submission #711359

#TimeUsernameProblemLanguageResultExecution timeMemory
711359xyzxyzJob Scheduling (CEOI12_jobs)C++14
25 / 100
337 ms39056 KiB
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); long long n, d, m; cin >> n >> d >> m; vector<int> requests(m); vector<vector<int>> auftrage(m); int upper = 0, lower = 1; for (int i = 1; i <= m; i++) { int a; cin >> a; a--; requests[a]++; auftrage[a].push_back(i); upper = max(upper, requests[a]); } while(upper-lower>0){ int maschinen = (lower+upper)/2; int last = 0, rest = requests[0]; bool pos = true; for(int i=0; i<m && pos; i++){ if (i - last > d) pos = false; int tmp = maschinen; while(tmp>0 && last+1<=i){ int tmp2 = min(rest, tmp); tmp -= tmp2; rest -= tmp2; if(rest == 0 && last+1<=i){ last++; rest = requests[last]; } } } if(pos){ //cout << maschinen << endl; upper = maschinen; } else lower = maschinen+1; } cout << lower << endl; int curr = 0; int j = auftrage[curr].size()-1; for (int b = 0; b < n; b++) { for (int i = 0; i < lower && b >= curr && curr < auftrage.size() && j >= 0; i++) { cout << auftrage[curr][j] << " "; j--; if (j < 0) { curr++; if(curr < auftrage.size()) j = auftrage[curr].size()-1; } } cout << 0 << endl; } return 0; }

Compilation message (stderr)

jobs.cpp: In function 'int main()':
jobs.cpp:48:50: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   48 |   for (int i = 0; i < lower && b >= curr && curr < auftrage.size() && j >= 0; i++) {
      |                                             ~~~~~^~~~~~~~~~~~~~~~~
jobs.cpp:53:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   53 |     if(curr < auftrage.size()) j = auftrage[curr].size()-1;
      |        ~~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...