# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
569173 | gcconure | Job Scheduling (CEOI12_jobs) | C++17 | 371 ms | 65536 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;
array<vector<ll>,100001> arr;
bool ok(ll dd){
auto copy=v;
for(ll i = 0; i < 100001; i++){
arr[i]={};
}
ll day = 0;
ll done=0;
bool works=true;
while(done<m){
if(day==n){
works=false;
break;
}
for(ll i = 0; i < min(ll(v.size()+1),ll(dd)); i++){
arr[day].push_back(v.back().second);
v.pop_back();
}
day++;
done+=dd;
}
v=copy;
return works;
}
int main(){
cin >> n >> d >> m;
for(ll i = 0; i < m; i++){
ll x; cin >> x;
v.push_back({x,i});
}
sort(v.rbegin(), v.rend());
ll l = 1,r=m;
array<vector<ll>,100001> cur;
while(l<r){
ll mid = (l+r)/2;
if(ok(mid)){
cur=arr;
r=mid;
}
else{
l=mid+1;
}
}
cout << l << "\n";
int counter = 0;
for(vector<ll> vv:cur){
if(counter==n){
break;
}
for(ll i:vv){
cout << i+1 << " ";
}
cout << 0 << "\n";
counter++;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |