Help me in solving FORESTGA problem

My issue

why my code is failing if i take hi=10000 it is partially correct else if i take big value of hi other test cases are falling

My code

#include <bits/stdc++.h>
using namespace std;
bool check(vector<pair<long long,long long>>&v,long long mid,long long L,long long W){
    long long res=0;
    for(long long i=0;i<v.size();i++){
        if((v[i].first+(v[i].second*mid))>=L){
            res+=v[i].first+(v[i].second*mid);
        }
    }
    if(res>=W) return true;
    else return false;
}
int main() {
    long long N,W,L;
	cin>>N>>W>>L;
    vector<pair<long long,long long>>v(N);
    for(long long i=0;i<N;i++){
        long long h,r;
        cin>>h>>r;
        pair<long long,long long>p(h,r);
        v.push_back(p);
    }
    long long lo=0;
    long long hi=1000000000000000000;
    long long ans=0;
    while(lo<=hi){
        long long mid=lo+(hi-lo)/2;
        if(check(v,mid,L,W)){
            ans=mid;
            hi=mid-1;
        }
        else lo=mid+1;
    }
    cout<<ans<<endl;


}

Learning course: Jump from 2* to 3*
Problem Link: Forest Gathering Practice Problem in Jump from 2* to 3* - CodeChef