# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
680287 | SriniV | Job Scheduling (CEOI12_jobs) | C++14 | 368 ms | 17140 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 n , d , m;
vector<pair < int , int > > jobs;
bool valid(int machines){
int day = 1;
int count = 0;
for(auto job : jobs){
if(job.first>day){
count = 0;
day = job.first;
}
if(count==machines){
count = 0;
day++;
}
if(day - job.first > d){
return false;
}
count++;
}
return true;
}
int main(){
cin >> n >> d >> m;
jobs.resize(m);
for(int i = 0;i<m;i++){
cin >> jobs[i].first;
jobs[i].second = i+1;
}
sort(jobs.begin() , jobs.end());
int left = 1 , right = m;
int answer = -1;
while(left<=right){
int middle = left + (right - left)/2;
if(valid(middle)){
answer = middle;
right = middle - 1;
} else {
left = middle + 1;
}
}
cout << answer<<"\n";
int count = 0;
for(int day = 1;day<=n;day++){
for(int i = 0;i<answer;i++){
if(jobs[count].first>day||count==m)break;
cout << jobs[count++].second<<" ";
}
cout << 0 << "\n";
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |