Submission #1043793

#TimeUsernameProblemLanguageResultExecution timeMemory
1043793dpsaveslivesJob Scheduling (CEOI12_jobs)C++17
35 / 100
1097 ms34384 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; multiset<int> machines; for(int i = 0;i<mid;++i) machines.insert(0); bool good = true; for(int i = 0;i<times.size();++i){ int val = *(machines.begin()); if(val+1 > times[i].f+D){ good = false; break; } machines.insert(val+1); machines.erase(machines.begin()); } if(good){ hi = mid; } else{ lo = mid+1; } } cout << lo << "\n"; multiset<int> machines; for(int i = 0;i<lo;++i) machines.insert(0); for(int i = 0;i<times.size();++i){ int val = *(machines.begin()); machines.insert(val+1); sched[val+1].push_back(times[i].s); machines.erase(machines.begin()); } 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:23: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]
   23 |         for(int i = 0;i<times.size();++i){
      |                       ~^~~~~~~~~~~~~
jobs.cpp:42: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]
   42 |     for(int i = 0;i<times.size();++i){
      |                   ~^~~~~~~~~~~~~
jobs.cpp:53:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   53 |         for(int j = 0;j<sched[i].size();++j){
      |                       ~^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...