# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
923034 | MegatronRobo | Job Scheduling (CEOI12_jobs) | C++17 | 259 ms | 27280 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;
int main(){
cin.tie(0)->sync_with_stdio(0);
int N, D, M;
cin>>N>>D>>M;
vector<int> req_counter(N+1);
vector<vector<int>> req_atDay(N+1);
for(int i=0;i<M;i++){
int a;
cin>>a;
req_counter[a]++;
req_atDay[a].push_back(i+1);
}
int lo=1, hi=M+1;
while(lo<hi){
int mid = lo+(hi-lo)/2; // no. of machines
vector<int> temp=req_counter;
for(int i=1;i<N;i++){
temp[i]=max(temp[i]-mid, 0);
temp[i+1]+=temp[i];
}
if(temp[N]<=mid){
// then possible
hi=mid;
}else{
lo=mid+1;
}
}
// we got our ans=lo
cout<<lo<<endl;
// need to show process
vector<vector<int>> reschedule;
reschedule.push_back({});
int curr_count=0;
for(int i=1;i<req_atDay.size();i++){
for(int j=0;j<req_atDay[i].size();j++){
if((curr_count+1)%lo==0){
curr_count=0;
reschedule.back().push_back(req_atDay[i][j]);
reschedule.push_back({});
}else{
curr_count++;
reschedule.back().push_back(req_atDay[i][j]);
}
}
}
if(reschedule.back()==vector<int>()){
reschedule.pop_back();
}
for(int i=0;i<N;i++){
if(i>=reschedule.size()){
goto other;
}
for(int j=0;j<lo;j++){
cout<<reschedule[i][j]<<" ";
}
other:;
cout<<0<<endl;
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |