제출 #650832

#제출 시각아이디문제언어결과실행 시간메모리
650832borisAngelovJob Scheduling (CEOI12_jobs)C++11
100 / 100
434 ms26184 KiB
#include <iostream> #include <vector> #include <algorithm> using namespace std; const int MAXN = 100005; int n, m, d; vector<pair<int, int>> jobs; pair<bool, vector<vector<int>>> check(int machines) { vector<vector<int>> schedule; schedule.resize(n + 1); int currJob = 0; for (int day = 1; day <= n; day++) { for (int j = 0; j < machines; j++) { if (jobs[currJob].first > day) break; if (jobs[currJob].first + d >= day) { schedule[day].push_back({jobs[currJob++].second}); } else { return {false, schedule}; } if (currJob == m) { return {true, schedule}; } } } return {false, schedule}; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> d >> m; for (int i = 1; i <= m; i++) { int day; cin >> day; jobs.push_back({day, i}); } sort(jobs.begin(), jobs.end()); int l = 1; int r = m; while (l <= r) { int mid = (l + r) / 2; if (check(mid).first) r = mid - 1; else l = mid + 1; } cout << l << "\n"; vector<vector<int>> schedule = check(l).second; for (int i = 1; i <= n; i++) schedule[i].push_back(0); for (int i = 1; i <= n; i++) { cout << schedule[i][0]; for (int j = 1; j < schedule[i].size(); j++) cout << " " << schedule[i][j]; cout << "\n"; } return 0; }

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

jobs.cpp: In function 'int main()':
jobs.cpp:68:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   68 |         for (int j = 1; j < schedule[i].size(); j++) cout << " " << schedule[i][j];
      |                         ~~^~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...