# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
870290 | nhatvpm | Job Scheduling (CEOI12_jobs) | C++17 | 187 ms | 16896 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld=long double;
void setIO(string name) {
freopen((name+".in").c_str(),"r",stdin);
freopen((name+".out").c_str(),"w",stdout);
}
int dx[]={1,-1,0,0},dy[]={0,0,1,-1};
void solve(){
int n,d,m;
cin>>n>>d>>m;
vector<pair<int,int>> a(m);
for (int i=0;i<m;i++){
int x;
cin>>x;
a[i]={x+d,i+1};
}
sort(a.begin(),a.end());
int lo=1,hi=m;
while (lo<hi){
int mid=lo+(hi-lo)/2;
bool ok=1;
for (int i=1,x=0;i<=n&&x<m;i++){
int k=min(m-1,x+mid-1);
if (a[k].first<i){
ok=0;
break;
}
x=k+1;
}
if (ok) hi=mid;
else lo=mid+1;
}
cout<<lo<<'\n';
int x=0;
for (int i=1;i<=n;i++){
if (x==m){
cout<<"0\n";
continue;
}
int k=min(m-1,x+lo-1);
for (int j=x;j<=k;j++) cout<<a[j].second<<' ';
x=k+1;
cout<<"0\n";
}
}
int main(){
//setIO("");
ios_base::sync_with_stdio(0);
cin.tie(0);
int tc=1;
//cin>>tc;
while (tc--){
solve();
}
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |