Submission #480478

#TimeUsernameProblemLanguageResultExecution timeMemory
480478imaginary_unitJob Scheduling (CEOI12_jobs)C++17
0 / 100
145 ms8148 KiB
#include <bits/stdc++.h> #define ll long long using namespace std; int n, d, m, a[1'000'000]; bool ok(int mch) { priority_queue<int> pq; for(int i=0; i<mch; i++){ pq.push(-1); } for(int i=0; i<m; i++){ int cur=pq.top(); pq.pop(); cur*= -1; if(a[i]-cur-1 > d){ return 0; } pq.push(-cur-1); } return 1; } int minMachines(int l, int r) { while(r-l>1){ int m=(l+r)/2; if(ok(m)){ r=m; } else{ l=m; } } return r; } int main() { //freopen("angry.in", "r", stdin); //freopen("angry.out", "w", stdout); scanf("%d %d %d", &n, &d, &m); for(int i=0; i<m; i++){ scanf("%d", &a[i]); } sort(a, a+m); cout << minMachines(1, n); return 0; }

Compilation message (stderr)

jobs.cpp: In function 'int main()':
jobs.cpp:44:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   44 |     scanf("%d %d %d", &n, &d, &m);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
jobs.cpp:46:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   46 |         scanf("%d", &a[i]);
      |         ~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...