Help me in solving WARRIORCHEF problem

My issue

My code

#include <iostream>
#include <vector>
#include <numeric>
using namespace std;

int main() {
    int t;
    cin >> t;
    
    while (t--) {
        int n, h;
        cin >> n >> h;
        
        vector<int> A(n);
        for (int i = 0; i < n; i++) {
            cin >> A[i];
        }

        int sum = accumulate(A.begin(), A.end(), 0);

        if (h >= sum) {
            cout << "0" << endl;
        } else {
            cout <<sum-h+1 << endl;
        }
    }
    
    return 0;
}

Problem Link: WARRIORCHEF Problem - CodeChef

your approach is incorrect,

we need to use binary search, you can take help from my solution:
https://www.codechef.com/viewsolution/1022176053