Submission #532891

#TimeUsernameProblemLanguageResultExecution timeMemory
532891louiskwokJob Scheduling (CEOI12_jobs)C++17
55 / 100
448 ms13636 KiB
#include <bits/stdc++.h> using namespace std; struct Job { int id; int day; bool operator<(const Job arb) const { return day < arb.day; } } job[1000005]; int n,d,m; bool possible(int x) { int daycnt = 0; int it = 1; while (it<=m) { int cnt = 0; daycnt++; for (;it<=m&&cnt<x;it++) { if (job[it].day+d<daycnt) return false; cnt++; } } if (daycnt>n) return false; return true; } int main() { cin >> n >> d >> m; for (int i=1;i<=m;i++) { cin >> job[i].day; job[i].id = i; } sort(job+1,job+m+1); int lo = 1,hi = 1000000; while (lo<hi) { int mid = lo+(hi-lo)/2; if (possible(mid)) hi = mid; else lo = mid+1; } cout << lo << endl; int it = 1; int daycnt = 0; while (it<=m) { daycnt++; int cnt = 0; for (;it<=m&&cnt<lo;it++) { cnt++; cout << job[it].id << ' '; } cout << 0 << endl; } for (int i=daycnt;i<n;i++) cout << 0 << endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...