Help me in solving MINEAT problem

My issue

I find my logic is good with good with sample test cases but I don’t know what’s happening all other test cases

My code

#include <bits/stdc++.h>
using namespace std;

int h;
const int N= 1e5 +10;


bool predicate(vector<int>& a,int k){
    int hr=0;
    for (auto x : a){
        hr+=x/k+((x%k==0)?0:1);
    }
    return hr<=h;
}
int main() {
	// your code goes here
	int t,temp;
	int n;
	cin>>t;
	while(t--){
	    vector<int> a;
	    cin>>n>>h;
	    for (int i=0;i<n;i++){
            cin>>temp;
            a.push_back(temp);
        }
	    int l=1,r=n,m;
	    while(r-l>1){
	        m=(l+r)/2;
	        if(predicate(a,m)) r=m;
	        else l=m+1;
	    }
	    if(predicate(a,l)) cout<<l<<endl;
	    else cout<<r<<endl;
	}
	return 0;
}

Problem Link: MINEAT Problem - CodeChef

@mnayan
just a little mistake higher range would be >10^9 since h is upto 10^9 so for safer side take it as 10^18 and use long long int to avoid integer overflow
i have corrected these in your code.

#include <bits/stdc++.h>
using namespace std;

int h;
const int N= 1e5 +10;


bool predicate(vector<int>& a,long long int k){
    long long int hr=0;
    for (auto x : a){
        hr+=x/k+((x%k==0)?0:1);
    }
    return hr<=h;
}
int main() {
	// your code goes here
	int t,temp;
	int n;
	cin>>t;
	while(t--){
	    vector<int> a;
	    cin>>n>>h;
	    for (int i=0;i<n;i++){
            cin>>temp;
            a.push_back(temp);
        }
	   long long int l=0,r=1e18,m;
	    while(l<r){
	        m=l+(r-l)/2;
	        if(predicate(a,m)) r=m;
	        else l=m+1;
	    }
	    if(predicate(a,l)) cout<<l<<endl;
	    else cout<<r<<endl;
	}
	return 0;
}