# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
532891 | louiskwok | Job Scheduling (CEOI12_jobs) | C++17 | 448 ms | 13636 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |