제출 #650822

#제출 시각아이디문제언어결과실행 시간메모리
650822borisAngelovJob Scheduling (CEOI12_jobs)C++11
0 / 100
445 ms26372 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 currMachineIdx = 1; int currDay = 1; for (auto [day, idx] : jobs) { if (currDay > day + d || currDay > n) { return {false, schedule}; } schedule[currDay].push_back(idx); currMachineIdx++; if (currMachineIdx == machines + 1) { currMachineIdx = 1; currDay++; } } return {true, 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 << endl; 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++) { for (auto idx : schedule[i]) cout << idx << " "; cout << "\n"; } return 0; }

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

jobs.cpp: In function 'std::pair<bool, std::vector<std::vector<int> > > check(int)':
jobs.cpp:20:15: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   20 |     for (auto [day, idx] : jobs) {
      |               ^
jobs.cpp: In function 'int main()':
jobs.cpp:66:9: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   66 |         for (auto idx : schedule[i]) cout << idx << " "; cout << "\n";
      |         ^~~
jobs.cpp:66:58: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   66 |         for (auto idx : schedule[i]) cout << idx << " "; cout << "\n";
      |                                                          ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...