제출 #743137

#제출 시각아이디문제언어결과실행 시간메모리
743137vjudge1Job Scheduling (CEOI12_jobs)C++17
0 / 100
1090 ms64692 KiB
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 1; const int M = 1e6 + 1; priority_queue<pair<int,int>> q[M+10]; int arr[N+10]; int n,d,m; bool solve(int mid) { for(int i=1;i<=m;i++) { while (!q[i].empty()) q[i].pop(); } for(int i=1;i<=n;i++) { q[arr[i]].push({arr[i]+d, i}); } for(int i=1;i<m;i++) { while (q[i].size()>mid) { auto [a,b] = q[i].top(); q[i].pop(); if (a<=i) return false; q[i+1].push({a, b}); } } return q[m].size() <= mid; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cin >> m >> d >> n; for(int i=1;i<=n;i++) cin >> arr[i]; int l = 1 , r = N; while (l < r) { int mid = (l + r) / 2; if (solve(mid)) r = mid; else l = mid + 1; } cout << l << '\n'; solve(l); for(int i=1;i<=m;i++) { while (!q[i].empty()) { auto [a,b] = q[i].top(); q[i].pop(); cout << b << ' '; } cout << "0\n"; } return 0; }

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

jobs.cpp: In function 'bool solve(int)':
jobs.cpp:16:27: warning: comparison of integer expressions of different signedness: 'std::priority_queue<std::pair<int, int> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   16 |         while (q[i].size()>mid) {
      |                ~~~~~~~~~~~^~~~
jobs.cpp:22:24: warning: comparison of integer expressions of different signedness: 'std::priority_queue<std::pair<int, int> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   22 |     return q[m].size() <= mid;
      |            ~~~~~~~~~~~~^~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...