analysis
It’s written in the book with a big pile.
Greedy first choice: Divide
the time for drying clothes
and then judge whether you can finish drying all in this time.
You can change this time to the right boundary,
otherwise it +1 becomes the left boundary
Upload code
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int n,m,t,l,r,ans;
int a[500001],x[500001];
int pd(int mid)
{
int j=0;
for(int i=1;i<=n;i++)
{
if(a[i]>mid)
{
int c=x[i]-mid*m;
if(c%t!=0) j+=c/t+1;
else j+=c/t;
}
if(j>mid) return 0;
}
return 1;
}
int main()
{
cin>>n>>m>>t;
for(int i=1;i<=n;i++)
{
cin>>a[i];
x[i]=a[i];
if(a[i]%m!=0)
{
a[i]=a[i]/m+1;
}
else a[i]=a[i]/m;
r=max(r,a[i]);
}
l=1;
while(l<r)
{
int mid=(l+r)/2;
if(pd(mid))
{
r=mid;
}
else l=mid+1;
}
cout<<l;
}