# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1000164 | codexistent | Job Scheduling (CEOI12_jobs) | C++14 | 340 ms | 14160 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i = a; i <= b; i++)
#define MAXN 100005
#define MAXM 1000000
int n, d, m, arr[MAXN];
pair<int, int> req[MAXM];
int main(){
cin >> n >> d >> m;
FOR(i, 1, n) arr[i] = 0;
FOR(i, 1, m){
int x; cin >> x;
arr[x]++;
req[i - 1] = {x, i};
}
sort(req, req + m);
// 4762
multiset<int> s;
FOR(i, 1, 1 + d) s.insert(0);
int a = 1, b = m;
while(a < b){
int mid = (a + b) / 2;
bool valid = true;
int k = -1;
FOR(i, 1, n){
int j = 1;
while(j <= mid && (k + 1 < m) && (req[k + 1].first <= i && i <= req[k + 1].first + d)){
j++, k++;
}
//cout << k + 1 << " " << req[k + 1].first << " ~ " << i << endl;
}
if(k != m - 1) valid = false;
//cout << " YOYO m " << a << " is " << valid << " and we see " << k << endl;
if(valid){
b = mid;
}else{
a = mid + 1;
}
}
cout << a << endl;
int k = -1;
FOR(i, 1, n){
int j = 1;
while(j <= a && (k + 1 < m) && (req[k + 1].first <= i && i <= req[k + 1].first + d)){
cout << req[k + 1].second << " ";
j++, k++;
}
cout << "0" << endl;
}
}
/*
8 2 12
1 2 4 2 1 3 5 6 2 3 6 4
2 0 8
2 2 2 2 1 2 2 2
*/
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |