# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
743212 | vjudge1 | Job Scheduling (CEOI12_jobs) | C++17 | 275 ms | 29340 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;
struct deads
{
int day,work,dead;
bool operator<(const deads&d2)const{
return day<d2.day;
}
};
vector<deads> vc,copys;
int n,d,m,a,l = 1,r = 1e9,ans = 1e9+7;
int main()
{
ios_base::sync_with_stdio(0),cin.tie(0);
cin>>n>>d>>m;
for(int i = 1; i<=m; ++i){
cin>>a;
vc.push_back({a,i,a+d});
}
sort(vc.begin(), vc.end());
for(auto [day,work,dead]:vc){
copys.push_back({day,work,dead});
}
while(l<r){
int mid = (l+r)>>1;
int cnt = 0;
bool ck = 0;
int ps = 0;
for(int i = 0; i<vc.size(); ++i){
if(vc[i].day+ps==vc[i].dead){
ck = 1;
break;
}
++cnt;
if(cnt==mid){
cnt = 0;
ps++;
}
if(ck) break;
}
if(ck) l = mid+1;
else r = mid;
vc = copys;
}
int k = m/l+(m%l!=0);
cout<<k<<"\n";
int cnt = 0,c = 0;
for(auto [day,work,dead]:vc){
if(cnt==k){
cnt = 0;
++c;
cout<<0<<"\n";
}
++cnt;
cout<<work<<" ";
}
if(c!=m) cout<<"0\n";
for(int i = 0; i<n-l; ++i) cout<<0<<"\n";
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |