제출 #693477

#제출 시각아이디문제언어결과실행 시간메모리
693477ojuzuser12Job Scheduling (CEOI12_jobs)C++17
49 / 100
236 ms15688 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<pair<int, int>> jobs(M); for(int i = 0; i < M; i++) { cin >> jobs[i].first; jobs[i].second = i; } sort(jobs.begin(), jobs.end()); long long l = 1, r = M, mid; while(l < r) { mid = (l + r) / 2; bool works = ((M + mid - 1) / mid <= N); int i = 0; for(long long d = 0; d < N; d++) { for(long long c = 0; c < mid; c++) { if(d + 1 < jobs[i].first) break; if(i >= M) break; if(d + 1 - jobs[i].first > D) { works = false; break; } i++; } if(!works) break; } if(works) { r = mid; } else { l = mid + 1; } } cout << r << '\n'; int i = 0; for(long long d = 0; d < N; d++) { for(long long c = 0; c < mid; c++) { if(d + 1 < jobs[i].first) break; if(i >= M) break; cout << jobs[i].second + 1 << ' '; i++; } cout << 0 << '\n'; } }

컴파일 시 표준 에러 (stderr) 메시지

jobs.cpp: In function 'int main()':
jobs.cpp:14:29: warning: 'mid' may be used uninitialized in this function [-Wmaybe-uninitialized]
   14 |     long long l = 1, r = M, mid;
      |                             ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...