# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
638265 | NONTAC | Job Scheduling (CEOI12_jobs) | C++11 | 691 ms | 43236 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;
typedef pair<int,int> ii;
int n,m,d;
ii a[1000000];
vector<vector<int> > ans;
bool check(int x)
{
int j=0;
vector<vector<int> > days(n+1);
for(int i=1;i<=n;i++){
int cnt=x;
if(a[j].first> i+d) return false;
while(cnt && a[j].first <= i+d){
cnt--;
days[i].push_back(a[j].second+1);
j++;
if(j==m){
ans.assign(days.begin(),days.end());
return true;
}
}
}
return false;
}
int last_true()
{
int lo=1, hi=m;
while(lo<hi){
int mid=lo + (hi-lo)/2;
if(check(mid)){
hi=mid;
}
else{
lo=mid+1;
}
}
check(lo);
return lo;
}
int main()
{
//freopen("test.in","r",stdin);
//freopen("test.out","w",stdout);
cin>>n>>d>>m;
for(int i=0;i<m;i++){
cin>>a[i].first;
a[i].second=i;
}
sort(a,a+m);
cout<<last_true()<<endl;
for(int i=1;i<=n;i++){
for(int j=0;j<ans[i].size();j++) cout<<ans[i][j]<<" ";
cout<<0<<endl;
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |