제출 #499636

#제출 시각아이디문제언어결과실행 시간메모리
499636Shreyan_PaliwalJob Scheduling (CEOI12_jobs)C++17
0 / 100
455 ms13732 KiB
#include <algorithm> #include <iostream> #include <vector> using namespace std; vector<pair<int, int>> jobs; int n, d, m; bool works(int mid) { int counter = 0; for (int i = 0; i < jobs.size(); i++) { if ((counter / 3) + 1 <= jobs[i].first + d) { counter++; } else { return false; } } return true; } int main() { // freopen("jobscheduling.in", "r", stdin); cin >> n >> d >> m; jobs = vector<pair<int, int>>(m); for (int i = 0; i < m; i++) { cin >> jobs[i].first; jobs[i].second = i + 1; } sort(jobs.begin(), jobs.end()); int lo = 1; int hi = 1000000; while (lo != hi) { int mid = (lo + hi) / 2; if (works(mid)) { hi = mid; } else { lo = mid + 1; } } cout << lo << endl; int counter = 0; for (int i = 0; i < n; i++) { if (counter < jobs.size()) for (int j = 0; j < lo; j++) { if (counter < jobs.size()) // cout << 0 * (counter++) << " "; cout << jobs[counter++].second << " "; else break; } cout << 0 << endl; } return 0; }

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

jobs.cpp: In function 'bool works(int)':
jobs.cpp:12:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   12 |   for (int i = 0; i < jobs.size(); i++) {
      |                   ~~^~~~~~~~~~~~~
jobs.cpp: In function 'int main()':
jobs.cpp:51:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   51 |     if (counter < jobs.size())
      |         ~~~~~~~~^~~~~~~~~~~~~
jobs.cpp:53:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   53 |         if (counter < jobs.size())  // cout << 0 * (counter++) << " ";
      |             ~~~~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...