This solution fails for the fourth part of the test cases. Can someone tell me what type of test cases it is failing?
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<string, string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vii;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef unordered_map<string,int> usi;
typedef unordered_map<int,int> uii;
typedef unordered_set<int> ui;
#define FOR(a, b, c) for (int a = b; a < c; ++a)
#define FORN(a, b, c) for (int a = b; a <= c; ++a)
#define FORD(a, b, c) for (int a = b; a >= c; --a)
#define FORSQ(a, b, c) for (int a = b; a * a <= c; ++a)
#define FORC(a, b, c) for (char a = b; a <= c; ++a)
#define FOREACH(a, b) for (auto&(a) : (b))
#define REP(i, n) FOR(i,0, n)
#define REPN(i, n) FORN(i,1, n)
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define SQR(x) ((ll)(x) * (x))
#define RESET(a, b) memset(a, b, sizeof(a))
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ALL(v) v.begin(), v.end()
#define ALLA(arr, sz) arr, arr + sz
#define SIZE(v) (int)v.size()
#define SORT(v) sort(ALL(v))
#define REVERSE(v) reverse(ALL(v))
#define SORTA(arr, sz) sort(ALLA(arr, sz))
#define REVERSEA(arr, sz) reverse(ALLA(arr, sz))
#define PERMUTE next_permutation
#define TC(t) while(t--)
#define debug(x) cout<<#x<<' '<<x<<'\n'
#define yes cout<<"Yes\n"
#define no cout<<"No\n"
#define fsp(x) fixed<<setprecision(x)
#define nl cout<<"\n"
const string all = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
const string number = "0123456789";
const string upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const string lower = "abcdefghijklmnopqrstuvwxyz";
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t;
cin>>t;
TC(t){
int n,h;
cin>>n>>h;
vi a(n);
int sum=0;
FOR(i,0,n)
{
cin>>a[i];
sum+=a[i];
}
if(h>sum)
cout<<"0\n";
else
{
map<int,int>mp;
FOR(i,0,n)
{
mp[a[i]]++;
}
map<int,int>::iterator itr=mp.begin();
int res=0;
while(itr!=mp.end())
{
res=itr->fi;
h+=(itr->se)*(itr->fi);
if(h>sum)
break;
itr++;
}
cout<<res<<"\n";
}
}
return 0;
}