# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
93993 | rkocharyan | Job Scheduling (CEOI12_jobs) | C++14 | 68 ms | 380 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 7;
int n, d, m;
int f[N];
bool check(int t) {
deque < pair <int, int> > h;
for(int i = 1; i <= n; i++) {
h.emplace_back(i, f[i]);
int cur_t = t;
while(!h.empty() && cur_t) {
if(i - h[0].first > d) return false;
int next_t = cur_t;
next_t -= min(h[0].second, cur_t);
h[0].second -= min(h[0].second, cur_t);
cur_t = next_t;
if(h[0].second == 0) {
h.pop_front();
}
}
}
if(h.size()) return false;
return true;
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cin >> n >> d >> m;
for(int i = 0; i < m; i++) {
int x;
cin >> x;
f[x]++;
}
int low = 1, high = n, best = n;
while(low <= high) {
int mid = (low + high) >> 1;
if(check(mid)) {
best = mid;
high = mid - 1;
} else {
low = mid + 1;
}
}
cout << best << '\n';
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |