# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
581654 | updown1 | Job Scheduling (CEOI12_jobs) | C++17 | 1093 ms | 7244 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 = int;
ll n,d,m;
pair<int, int> v[1000000];
bool ok(ll dd){
ll day = 1, w = 0;
while(day<=n){
for(ll i = 0; i < dd; i++){
w++;
if(w==m) {
return true;
}
if(day>v[w].first+d){
return false;
}
if(day<v[w].first){
w--;
}
}
day++;
}
return false;
}
int main(){
ios_base::sync_with_stdio(0); cin.tie(0);
cin >> n >> d >> m;
for(ll i = 0; i < m; i++){
cin >> v[i].first;
v[i].second = i;
}
sort(v, v+m);
ll l = 1,r=m;
while(l<r){
ll mid = (l+r)/2;
if(ok(mid)){
r=mid;
}
else{
l=mid+1;
}
}
ll counter=0;
ll cur = 0;
cout << l << "\n";
while(cur<m){
counter++;
for(ll i = 0; i < l; i++){
cout << v[cur].second+1 << " ";
cur++;
if(cur==m){
break;
}
}
cout << "0\n";
}
for(ll i = 0; i < n-counter; i++){
cout << 0 << "\n";
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |