# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
84453 | someone_aa | Job Scheduling (CEOI12_jobs) | C++17 | 1085 ms | 33792 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>
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;
const int maxn = 100100;
multiset<int>tasks;
int n, d, m;
bool check(int x) {
multiset<int> curr = tasks;
for(int i=1;i<=n;i++) {
//cout<<i<<": \n";
for(int j=0;j<x && curr.size();j++) {
auto it = curr.lower_bound(i-d);
//cout<<"Found: "<<(*it)<<"\n";
if(curr.size() == 0 && it == curr.end()) break;
if(*it > i) break;
else curr.erase(it);
}
}
return curr.size() == 0;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cin>>n>>d>>m;
int x;
for(int i=1;i<=m;i++) {
cin>>x;
tasks.insert(x);
}
int index = m;
for(int cekor = m/2;cekor>0;cekor/=2) {
while(index-cekor>=0 && check(index-cekor)) index-=cekor;
}
cout<<index<<"\n";
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |