My issue
i found other solution after contest many of them are writting this soluion:
max((x1-y2),ceil(x/(y+1)))
anyone please explain how this will minimize the maximum sum of subarray.
for example:
x=50, y=10
according to above solution output will be 30 which is wrong clearly rather it should be only ceil(x/(y+1)) i.e. output would be 5…
My code
#include <bits/stdc++.h>
using namespace std;
int main() {
// your code goes here
int t;
cin>>t;
while(t--){
double x,y;
cin>>x>>y;
if(x<=y)
cout<<1<<endl;
else{
cout<< ceil(x/(y+1))<<endl;
}
}
return 0;
}
Problem Link: Minimise Maximum Subarray Sum Practice Coding Problem - CodeChef