MINEAT
my last test case is failed while submiting my code. Please tell me which test case is failed
my code is below
#include<bits/stdc++.h>
using namespace std;
bool CanEat(int arr[], int n, int h, int k)
{
int time = 0;
int low = 0;
while(low < n)
{
if(arr[low] <= k)
{
time++;
low++;
}
else
{
time = time + arr[low]/k + 1;
low++;
}
}
return (time <= h);
}
int main()
{
int t = 0;
cin>>t;
while(t--)
{
int n=0, h=0;
cin>>n>>h;
int arr[n], mx = 0, ans = 0;
for(int i=0; i<n; i++)
{
cin>>arr[i];
mx = max(mx, arr[i]);
}
int low = 1, high = mx;
while(low <= high)
{
int mid = (low + high)/2;
if(CanEat(arr,n,h,mid) == true)
{
ans = mid;
high = mid -1;
}
else
{
low = mid + 1;
}
}
cout<<ans<<endl;
}
return 0;
}