# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
854389 | anhphant | Job Scheduling (CEOI12_jobs) | C++14 | 11 ms | 1628 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll N, D, M, A[100007];
void initialize() {
ios_base :: sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> N >> D >> M;
for(int i = 1; i <= M; ++i) {
cin >> A[i];
}
sort(A + 1, A + 1 + M);
//for(int i = 1; i <= M; ++i) cerr << A[i] << " "; cerr << endl;
}
bool check(ll MachinesCnt) {
//cerr << "MachinesCnt = " << MachinesCnt << endl;
int idx = 1;
for(int day = 1; day <= N; ++day) {
//cerr << "Day " << day << " : " << endl;
ll used_machines_in_day = 0;
while(idx <= M && used_machines_in_day < MachinesCnt) {
if (day < A[idx] || A[idx] + D < day) break;
//cerr << "job " << idx << " is going to work with time at " << A[idx] << endl;
used_machines_in_day++;
idx++;
}
//cerr << "used_machines_in_day : " << used_machines_in_day << endl;
//cerr << "used_machines_all_times : " << idx - 1 << endl;
//cerr << endl;
}
return idx > M;
}
void process() {
ll l = 1, r = N;
while(l < r) {
ll mid = (l + r) / 2;
if (check(mid)) r = mid;
else l = mid + 1;
}
cout << l;
}
int main() {
initialize();
process();
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |