# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
768301 | orcslop | Job Scheduling (CEOI12_jobs) | C++17 | 279 ms | 13784 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define sz(x) (int)(x).size()
const int MAXN = 1e5;
const int MAXM = 1e6;
int n, d, m;
pair<int, int> jobs[MAXM];
queue<int> q;
bool check(int machines){
while(!q.empty()) q.pop();
int index = 0;
for(int i = 1; i <= n; i++){
while(index < m && jobs[index].first <= i) {
q.push(jobs[index].first);
index++;
}
for(int j = 0; j < machines; j++){
if(!q.empty()) {
int sent = q.front();
if(i - sent > d) return false;
q.pop();
}
else break;
}
}
return q.empty();
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
cin >> n >> d >> m;
for(int i = 0; i < m; i++) {
cin >> jobs[i].first;
jobs[i].second = i + 1;
}
sort(jobs, jobs + m);
int low = 1, high = INT_MAX;
while (low < high) {
int mid = low + (high - low) / 2;
if (check(mid)) high = mid;
else low = mid + 1;
}
// cout << check(1000000);
cout << low << '\n';
while(!q.empty()) q.pop();
int index = 0;
for(int i = 1; i <= n; i++){
while(index < m && jobs[index].first <= i) {
q.push(jobs[index].second);
index++;
}
for(int i = 0; i < low; i++){
if(!q.empty()) {
int sent = q.front();
cout << sent << ' ';
q.pop();
}
else break;
}
cout << "0\n";
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |