# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
995732 | catsarecool5530 | Job Scheduling (CEOI12_jobs) | C++17 | 38 ms | 4044 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define endl "\n"
struct Line {
int start, end;
};
int maxDelay;
vector<int> schedule;
bool works(int machines) {
deque<pair<int, int>> todo;
int day = 0;
int currentmaxdelay = 0;
while (day < schedule.size() || !todo.empty()) {
todo.push_back({day, schedule[day]});
currentmaxdelay = max(currentmaxdelay, day - todo.front().first);
if (currentmaxdelay > maxDelay) return false;
int machinesAvailible = machines;
while (!todo.empty() && machinesAvailible > 0) {
if (todo.front().second > machinesAvailible) {
todo.front().second -= machinesAvailible;
machinesAvailible = 0;
} else {
machinesAvailible -= todo.front().second;
todo.pop_front();
}
}
//cout << day << endl;
day++;
}
return currentmaxdelay <= maxDelay;
}
int main() {
// fast io
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
//freopen("snowboots.in", "r", stdin);
//freopen("snowboots.out", "w", stdout);
int n, d, m; cin >> n >> d >> m;
maxDelay = d;
schedule = vector<int>(n);
for (int i = 0; i < m; i++) {
int temp; cin >> temp;
temp--;
schedule[temp]++;
}
int lo = 1; int hi = 1e9;
while (lo <= hi) {
int mid = (lo + hi) / 2;
if (!works[mid]) {
lo = mid + 1;
} else {
hi = mid - 1;
}
}
cout << lo +1 << endl;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |