# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
988490 | hansenhe | Job Scheduling (CEOI12_jobs) | C++14 | 340 ms | 42856 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define int long long
int n, d, m;
pair<int, int> req[1000005];
vector<vector<int>> out;
bool good(int mach){
vector<vector<int>> each(n + 1);
vector<int> day(mach + 1);
int cur = 1;
for (int i = 0; i < m; i++){
day[cur] = max(day[cur] + 1, req[i].first);
each[day[cur]].push_back(req[i].second);
if (day[cur] - req[i].first > d){
return false;
}
cur++;
cur %= mach;
if (cur == 0) cur = mach;
}
out = each;
return true;
}
signed main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
// freopen("split.in", "r", stdin);
// freopen("split.out", "w", stdout);
cin >> n >> d >> m;
for (int i = 0; i < m; i++){
cin >> req[i].first;
req[i].second = i + 1;
}
sort(req, req + m);
int a = 1, b = m;
while (a != b){
int mid = (a + b) / 2;
if (good(mid)){
b = mid;
} else {
a = mid + 1;
}
}
cout << a << "\n";
for (int i = 1; i <= n; i++){
for (int x : out[i]){
cout << x << " ";
}
cout << "0\n";
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |