Submission #1043805

#TimeUsernameProblemLanguageResultExecution timeMemory
1043805dpsaveslivesJob Scheduling (CEOI12_jobs)C++17
100 / 100
189 ms20076 KiB
#include <bits/stdc++.h> #define f first #define s second using namespace std; const int MAXN = 1e5+10; vector<int> sched[MAXN]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int N,D,M; cin >> N >> D >> M; vector<pair<int,int>> times(M); for(int i = 0;i<M;++i){ cin >> times[i].f; times[i].s = i+1; } sort(times.begin(),times.end()); int lo = 1, hi = M; ++hi; while(lo < hi){ int mid = lo+(hi-lo)/2; vector<int> machines(mid,0); bool good = true; for(int i = 0;i<times.size();++i){ if(machines[i%mid]+1 > times[i].f+D){ good = false; break; } machines[i%mid] = max(machines[i%mid]+1,times[i].f); } if(good){ hi = mid; } else{ lo = mid+1; } } cout << lo << "\n"; vector<int> machines(lo,0); for(int i = 0;i<times.size();++i){ machines[i%lo] = max(machines[i%lo]+1,times[i].f); //cout << machines[i%lo] << " " << times[i].f << "\n"; sched[machines[i%lo]].push_back(times[i].s); } for(int i = 1;i<=N;++i){ if(sched[i].size() == 0){ cout << 0 << "\n"; continue; } for(int j = 0;j<sched[i].size();++j){ cout << sched[i][j] << " "; } cout << 0 << "\n"; } return 0; }

Compilation message (stderr)

jobs.cpp: In function 'int main()':
jobs.cpp:22:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |         for(int i = 0;i<times.size();++i){
      |                       ~^~~~~~~~~~~~~
jobs.cpp:38:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |     for(int i = 0;i<times.size();++i){
      |                   ~^~~~~~~~~~~~~
jobs.cpp:48:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   48 |         for(int j = 0;j<sched[i].size();++j){
      |                       ~^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...