# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
455180 | inluminas | Job Scheduling (CEOI12_jobs) | C++17 | 258 ms | 20560 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include"bits/stdc++.h"
using namespace std;
#define ll long long
#define endl "\n"
#define fastio ios_base::sync_with_stdio(false)
const int lmt=1e5+10;
vector<int>adj[lmt],res[lmt];
int n,d,m,cnt[lmt];
int main(){
fastio;
cin>>n>>d>>m;
for(int i=1;i<=m;i++){
int a;
cin>>a;
adj[a].push_back(i);
cnt[a]++;
}
int lo=1,hi=m;
while(lo<hi){
int mid=(lo+hi)>>1,ache[lmt]={0},cur=1,bad=0;
for(int i=1;i<=n;i++){
for(int j=1;j<=cnt[i];j++){
while(cur<i || ache[cur]==mid) cur++;
if(cur-i>d){
bad=1;
break;
}
ache[cur]++;
}
if(bad) break;
}
if(bad) lo=mid+1;
else hi=mid;
}
int ache[lmt]={0},cur=1;
for(int i=1;i<=n;i++){
for(int j=1;j<=cnt[i];j++){
while(cur<i || ache[cur]==lo) cur++;
ache[cur]++;
res[cur].push_back(adj[i][j-1]);
}
}
cout<<lo<<endl;
for(int i=1;i<=n;i++){
for(int v:res[i]) cout<<v<<" ";
cout<<0<<endl;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |