# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
384206 | kaplanbar | Job Scheduling (CEOI12_jobs) | C++14 | 1093 ms | 13548 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
int n, d, m;
cin >> n >> d >> m;
vector<vector<int>> use(n);
for(int i = 0; i < m; i++) {
int x;
cin >> x;
use[x - 1].push_back(i);
}
auto check = [&](int co) -> vector<vector<int>> {
vector<vector<int>> ans(n);
queue<pair<int,int>> closest;
for(int i = 0; i < n; i++) {
for(int x : use[i]) {
closest.push({i + d, x});
}
if(!closest.empty() && closest.front().first < i) return vector<vector<int>>{};
for(int j = 0; j < co; j++) {
if(!closest.empty()) {
ans[i].push_back(closest.front().second);
closest.pop();
}
}
}
if(!closest.empty()) return vector<vector<int>>{};
return ans;
};
int l = 0, r = m;
while(l + 1 < r) {
int mid = (l + r) / 2;
if(!check(mid).empty()) r = mid;
else l = mid;
}
cout << r << "\n";
auto ans = check(r);
for(int i = 0; i < n; i++) {
for(int x : ans[i]) cout << x + 1 << " ";
cout << 0 << "\n";
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |