this is my code for painters problem
define ll long long
using namespace std;
int canPaint(vector v,ll time,ll p,ll t){
ll cp=1,ct=0;
for(ll i=0;i<v.size();i++){
ct+=(v[i]*t);
if(ct>time){
ct=v[i]*t;
cp++;
}
}
if(cp>p){
return false;
}
else{
return true;
}
}
int main() {
ll p,b,t;
cin>>b>>p>>t;
vector v;
for(ll i=0;i<b;i++){
ll x;
cin>>x;
v.push_back(x);
}
ll s=max_element(v.begin(),v.end());
s=st;
ll e=0;
e=accumulate(v.begin(),v.end(),0)*t;
ll res=INT_MAX;
while(s<=e){
ll mid=(s+e)/2;
if(canPaint(v,mid,p,t)){
res=mid;
e=mid-1;
}
else{
s=mid+1;
}
}
cout<<(res%(10000003))<<endl;
return 0;
}
it is passing all test cases when i change a line from :
res=min(res,mid);
to
res=mid;
previously it is not passing two test cases.
why is it so?