제출 #1043802

#제출 시각아이디문제언어결과실행 시간메모리
1043802dpsaveslivesJob Scheduling (CEOI12_jobs)C++17
80 / 100
1076 ms30800 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){ val = times[i].f-1; } 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()); if(val+1 < times[i].f){ val = times[i].f-1; } 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; }

컴파일 시 표준 에러 (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:45: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]
   45 |     for(int i = 0;i<times.size();++i){
      |                   ~^~~~~~~~~~~~~
jobs.cpp:59:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   59 |         for(int j = 0;j<sched[i].size();++j){
      |                       ~^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...