# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
581595 | gcconure | Job Scheduling (CEOI12_jobs) | C++17 | 1097 ms | 19496 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;
ll n,d,m;
vector<pair<ll,ll>> v;
bool ok(ll dd){
int day = 1, w = 0;
while(day<=n){
for(int i = 0; i < dd; i++){
w++;
if(w==v.size()){
return true;
}
if(day>v[w].first+d){
return false;
}
if(day<v[w].first){
w--;
}
}
day++;
}
return false;
}
int main(){
cin >> n >> d >> m;
for(ll i = 0; i < m; i++){
ll x; cin >> x;
v.push_back({x,i});
}
sort(v.begin(), v.end());
ll l = 1,r=m;
while(l<r){
ll mid = (l+r)/2;
if(ok(mid)){
r=mid;
}
else{
l=mid+1;
}
}
reverse(v.begin(), v.end());
ll counter =0 ;
cout << l << "\n";
while(!v.empty()){
counter++;
for(ll i = 0; i < l; i++){
cout << v.back().second+1 << " ";
v.pop_back();
if(v.empty()){
break;
}
}
cout << "0\n";
}
for(ll i = 0; i < n-counter; i++){
cout << 0 << "\n";
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |