제출 #696424

#제출 시각아이디문제언어결과실행 시간메모리
696424cfjasonJob Scheduling (CEOI12_jobs)C++17
80 / 100
1082 ms30412 KiB
#include <bits/stdc++.h> using namespace std; int main(int argc, char const *argv[]) { ios::sync_with_stdio(false); cin.tie(nullptr); int n, d, m; cin >> n >> d >> m; vector<vector<int>> requestsByDay(n); vector<string> validResults; for (int i = 0; i < m; i++) { int day; cin >> day; requestsByDay[day-1].push_back(i+1); } int lower = 0, upper = m+1; while (lower + 1 < upper) { int mid = (lower + upper) / 2; int reqIndex = 0; priority_queue<array<int, 2>, vector<array<int, 2>>, greater<>> line; bool valid = true; vector<string> results(n); for (int i = 0; i < n; i++) { for (int j = 0; j < requestsByDay[i].size(); j++) line.push(array<int, 2>{i, requestsByDay[i][j]}); for (int j = 0; j < mid; j++) { if (line.size()) { if (i - line.top()[0] > d) { valid = false; break; } results[i] += to_string(line.top()[1]) + " "; line.pop(); } else { break; } } results[i] += "0"; if (!valid) break; } if (line.size()) valid = false; if(valid){ validResults = results; upper = mid; } else{ lower = mid; } } cout << upper << endl; for (int i = 0; i < n; i++) { cout << validResults[i] << endl; } return 0; }

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

jobs.cpp: In function 'int main(int, const char**)':
jobs.cpp:29:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |             for (int j = 0; j < requestsByDay[i].size(); j++)
      |                             ~~^~~~~~~~~~~~~~~~~~~~~~~~~
jobs.cpp:23:13: warning: unused variable 'reqIndex' [-Wunused-variable]
   23 |         int reqIndex = 0;
      |             ^~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...