# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
772286 | 1ne | Job Scheduling (CEOI12_jobs) | C++14 | 137 ms | 16952 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
/*
* author : Apiram
* created: 04.07.2023 03:13:11
*/
#include<bits/stdc++.h>
using namespace std;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
int n,m,d;cin>>n>>d>>m;
vector<vector<int>>adj(n);
for (int i = 0;i<m;++i){
int x;cin>>x;
adj[x - 1].push_back(i);
}
int left = 0,right = m;
int pos = -1;
while(left<=right){
int mid = (left + right)>>1;
queue<int>q;
bool ok = true;
for (int i = 0;i<n;++i){
for (auto x:adj[i]){
q.push(i);
}
for (int j = 0;j<mid && !q.empty();++j){
if (i - q.front() > d){
ok = false;
break;
}
q.pop();
}
if (!ok)break;
}
if (!q.empty())ok = false;
if (ok){
right = mid - 1;
pos = mid;
}
else left = mid + 1;
}
cout<<pos<<'\n';
queue<int>q;
for (int i = 0;i<n;++i){
for (auto x:adj[i]){
q.push(x + 1);
}
for (int j = 0;j<pos && !q.empty();++j){
cout<<q.front()<<" ";
q.pop();
}
cout<<0<<'\n';
}
return 0;
}
/*
8 2 12
1 2 4 2 1 3 5 6 2 3 6 4
*/
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |