# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
870290 | nhatvpm | Job Scheduling (CEOI12_jobs) | C++17 | 187 ms | 16896 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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();
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |