# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
653661 | finn__ | Job Scheduling (CEOI12_jobs) | C++17 | 1097 ms | 19232 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
int main()
{
cin.tie(0);
ios_base::sync_with_stdio(0);
unsigned n, m, d;
cin >> n >> d >> m;
vector<pair<int32_t, unsigned>> jobs(m);
for (unsigned i = 0; i < m; i++)
{
cin >> jobs[i].first;
jobs[i].second = i + 1;
}
sort(jobs.begin(), jobs.end());
vector<int32_t> schedule;
int32_t min_machines = m;
int32_t a = 1, b = m;
while (a < b)
{
int32_t mid = (a + b + 1) / 2;
priority_queue<pair<int32_t, unsigned>, vector<pair<int32_t, unsigned>>, greater<pair<int32_t, unsigned>>> q;
bool possible = 1;
auto it = jobs.begin();
vector<int32_t> local_schedule;
for (int32_t i = 1; i <= n && possible; i++)
{
while (it != jobs.end() && it->first == i)
{
q.push(*it);
it++;
}
for (unsigned j = 0; j < mid && !q.empty(); j++)
{
if (i - q.top().first > d)
{
possible = 0;
break;
}
local_schedule.push_back(q.top().second);
q.pop();
}
local_schedule.push_back(0);
}
if (possible)
{
b = mid;
if (mid < min_machines)
{
min_machines = mid;
swap(local_schedule, schedule);
}
}
else
a = mid + 1;
}
cout << a << '\n';
for (int32_t x : schedule)
{
cout << x;
if (!x)
cout << '\n';
else
cout << ' ';
}
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |