# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
263425 | DS007 | Job Scheduling (CEOI12_jobs) | C++14 | 103 ms | 1224 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5, M = 1e6;
int a[N], cpy[N], n, d, m;
bool check(int mid) {
for (int i = 1; i <= n; i++)
cpy[i] = a[i];
for (int i = 1, last = 1; i <= n; i++) {
int left = mid;
while (left > 0 && last <= i) {
if (left >= cpy[last])
left -= cpy[last], last++;
else
cpy[last] -= left, left = 0;
}
if (last > n + 1)
exit(0);
if (i - last >= d)
return false;
}
return true;
}
int solveTestCase() {
cin >> n >> d >> m;
for (int i = 0; i < m; i++) {
int temp;
cin >> temp;
if (temp >= N)
exit(0);
a[temp]++;
}
int l = 1, h = M, ans = M;
while (l <= h) {
//cerr << l << " " << h << "\n";
int mid = (l + h) / 2;
if (check(mid))
ans = mid, h = mid - 1;
else
l = mid + 1;
}
cout << ans << "\n";
for (int i = 0; i < n; i++)
cout << "0\n";
return 0;
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int t = 1;
//cin >> t;
while (t--)
solveTestCase();
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |