# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
106641 | naoai | Job Scheduling (CEOI12_jobs) | C++14 | 487 ms | 20700 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define fin cin
#define fout cout
//ifstream fin("x.in"); ofstream fout("x.out");
const int mmax = 1e6 + 5;
int n, d, m;
int a[mmax + 1];
pair<int, int> v[mmax + 1];
bool check (int val) {
int i = 1;
for (int z = 1; z <= n; ++ z) {
int aux = i;
for (int j = i; j < i + val && a[j] <= z && j <= m; ++ j, ++ aux) {
if (a[j] + d < z)
return 0;
}
i = aux;
}
return 1;
}
int main() {
// ios::sync_with_stdio(0); cin.tie(nullptr);
cin >> n >> d >> m;
for (int i = 1; i <= m; ++ i) {
int x;
cin >> x;
a[i] = x;
v[i] = {x, i};
}
int n2 = 1;
for (n2 = 1; (n2 << 1) <= m; n2 <<= 1) {
}
sort(a + 1, a + m + 1);
int ans = m;
for (int step = n2; step > 0; step >>= 1) {
if (ans - step > 0 && check(ans - step)) {
ans -= step;
}
}
sort(v + 1, v + m + 1);
cout << ans << "\n";
int i = 1;
for (int z = 1; z <= n; ++ z) {
int aux = i;
for (int j = i; j < i + ans && a[j] <= z && j <= m; ++ j, ++ aux) {
cout << v[j].second << " ";
}
i = aux;
cout << "0\n";
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |