# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
94933 | popovicirobert | Job Scheduling (CEOI12_jobs) | C++14 | 231 ms | 14004 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define lsb(x) (x & (-x))
#define ll long long
#define ull unsigned long long
#define ld long double
// 217
// 44
using namespace std;
const int MAXM = (int) 1e6;
pair <int, int> arr[MAXM + 1];
inline bool check(int m, int d, int len) {
int pos = 1;
int cnt = 0;
while(pos <= m) {
cnt++;
int i;
for(i = pos; i < min(m + 1, pos + len) && cnt >= arr[i].first; i++) {
if(cnt - arr[i].first > d) {
return 0;
}
}
pos = i;
}
return 1;
}
int main() {
//ifstream cin("A.in");
//ofstream cout("A.out");
int i, n, m, d;
ios::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
cin >> n >> d >> m;
for(i = 1; i <= m; i++) {
cin >> arr[i].first;
arr[i].second = i;
}
sort(arr + 1, arr + m + 1);
int res = 0;
for(int step = 1 << 20; step; step >>= 1) {
if(check(m, d, res + step) == 0) {
res += step;
}
}
res++;
cout << res << "\n";
int pos = 1;
int cnt = 0;
for(i = 1; i <= n; i++) {
int j;
cnt++;
for(j = pos; j < min(m + 1, pos + res) && cnt >= arr[j].first; j++) {
cout << arr[j].second << " ";
}
cout << "0\n";
pos = j;
}
//cin.close();
//cout.close();
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |