# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
97641 | dalgerok | Job Scheduling (CEOI12_jobs) | C++17 | 1074 ms | 20284 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int n, d, m, a[10 * N], ans[10 * N];
vector < int > q[N], s[N];
inline bool check(int x){
queue < int > e;
for(int i = 1; i <= n; i++){
for(auto it : q[i]){
e.push(it);
}
for(int j = 1; j <= x && !e.empty(); j++){
if(a[e.front()] + d < i){
return false;
}
ans[e.front()] = i;
e.pop();
}
}
return e.empty();
}
int main(){
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];
q[a[i]].push_back(i);
}
int l = 1, r = m;
while(l < r){
int mid = (r + l) >> 1;
if(check(mid)){
r = mid;
}
else{
l = mid + 1;
}
}
check(l);
for(int i = 1; i <= m; i++){
s[ans[i]].push_back(i);
}
cout << l << "\n";
for(int i = 1; i <= n; i++){
for(auto it : s[i]){
cout << it << " ";
}
cout << "0\n";
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |