# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
743125 | vjudge1 | Job Scheduling (CEOI12_jobs) | C++17 | 1076 ms | 14948 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;
const int N = 1e5+1;
int n,d,m;
struct job
{
int dline,idx;
bool operator <(const job &x)const{
if(dline != x.dline) return dline > x.dline;
return idx > x.idx;
}
};
int ans;
vector<int> path;
priority_queue<job> pq;
int main()
{
ios_base::sync_with_stdio(0); cin.tie(0);
cin >> n >> d >> m;
for(int i=1;i<=m;++i)
{
int x;
cin >> x;
x += d;
pq.push({x,i});
}
// while(!pq.empty())
// {
// cout << pq.top().dline << " " << pq.top().idx << '\n';
// pq.pop();
// }
int l = 1,r = n;
while(l<=r)
{
priority_queue<job> tmp = pq;
int mid = (l+r)/2;
// cout << "mid = " << mid << '\n';
bool all = true;
bool cant = false;
int cnt=0;
for(int i=1;i<=n;++i)
{
for(int j=1;j<=mid;++j)
{
// cout << "day = " << i << " deadline now " << tmp.top().dline << '\n';
if(i > tmp.top().dline)
{
cant = true;
break;
}
if(!tmp.empty()) tmp.pop();
}
if(cant) break;
}
if((!cant) && tmp.empty())
{
r = mid-1;
ans = mid;
}
else l = mid+1;
// cout << "\n\n";
}
cout << ans << '\n';
// int d = 0;
// while(!pq.empty())
// {
// for(int i=1;i<=ans;++i)
// {
// cout << pq.top().idx << " ";
// pq.pop();
// }
// ++d;
// cout << "0\n";
// }
// while(d < n)
// {
// cout << "0\n";
// d++;
// }
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |