# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
520319 | krit3379 | Job Scheduling (CEOI12_jobs) | C++14 | 157 ms | 10636 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;
#define N 1000005
struct A{
int val,i;
bool operator<(const A& o)const{
return val<o.val;
}
};
A a[N];
int main(){
int n,m,d,i,j,l,r,mid,k,ans;
scanf("%d %d %d",&n,&d,&m);
for(i=1;i<=m;i++){
scanf("%d",&a[i].val);
a[i].i=i;
}
sort(a+1,a+m+1);
l=1,r=m;
while(l<=r){
mid=(l+r)/2;
for(i=1,j=1;i<=n&&j<=m;i++){
if(i>a[j].val+d)break;
k=mid;
while(j<=m&&a[j].val<=i&&k--)j++;
}
if(j>m)ans=mid,r=mid-1;
else l=mid+1;
}
printf("%d",ans);
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |