Language: C++

#include <iostream>
#include <algorithm>
#include <vector>
#include <string.h>

#define max(x, y)	(((x) > (y))? (x) : (y))
#define abs(x)		(((x) < 0)? (-1*(x)) : (x))

using namespace std;

int N,H;
struct data_t {
    int a;
    int b;
} ;

bool acmp( const data_t& left, const data_t& right ) {
    return left.a > right.a;
}
bool bcmp( const data_t& left, const data_t& right ) {
    return left.b > right.b;
}

int main() {
	int i,x=0;
	int a_max,b_max;
	
	cin >> N >> H;

	vector<data_t> dt(N);

	for ( i = 0; i < N; i++ ) {
		cin  >> dt[i].a >> dt[i].b; 
	}
	
	sort(dt.begin(), dt.end(), acmp);
	a_max = dt[0].a;
	
	while ( H  > 0 ) {
		sort(dt.begin(), dt.end(), bcmp);
		b_max = dt[0].b;
		if ( b_max > a_max ) {
			H -= b_max;
			dt[0].a = dt[0].b = 0;
		} else {
			H -= a_max;
		}
		x++;
		sort(dt.begin(), dt.end(), acmp);
		a_max = dt[0].a;
	}
	
	cout << x << endl;

	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:40:21: error: no matching function for call to 'sort(std::vector<data_t>::iterator, std::vector<data_t>::iterator, <unresolved overloaded function type>)'
   40 |                 sort(dt.begin(), dt.end(), bcmp);
      |                 ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:2:
/usr/include/c++/14/bits/stl_algo.h:4762:5: note: candidate: 'template<class _RAIter> void std::sort(_RAIter, _RAIter)'
 4762 |     sort(_RandomAccessIterator __first, _RandomAccessIterator __last)
      |     ^~~~
/usr/include/c++/14/bits/stl_algo.h:4762:5: note:   candidate expects 2 arguments, 3 provided
/usr/include/c++/14/bits/stl_algo.h:4793:5: note: candidate: 'template<class _RAIter, class _Compare> void std::sort(_RAIter, _RAIter, _Compare)'
 4793 |     sort(_RandomAccessIterator __first, _RandomAccessIterator __last,
      |     ^~~~
/usr/include/c++/14/bits/stl_algo.h:4793:5: note:   template argument deduction/substitution failed:
a.cc:40:21: note:   couldn't deduce template parameter '_Compare'
   40 |                 sort(dt.begin(), dt.end(), bcmp);
      |                 ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:86:
/usr/include/c++/14/pstl/glue_algorithm_defs.h:292:1: note: candidate: 'template<class _ExecutionPolicy, class _RandomAccessIterator, class _Compare> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, void> std::sort(_ExecutionPolicy&&, _RandomAccessIterator, _RandomAccessIterator, _Compare)'
  292 | sort(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp);
      | ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:292:1: note:   candidate expects 4 arguments, 3 provided
/usr/include/c++/14/pstl/glue_algorithm_defs.h:296:1: note: candidate: 'template<class _ExecutionPolicy, class _RandomAccessIterator> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, void> std::sort(_ExecutionPolicy&&, _RandomAccessIterator, _RandomAccessIterator)'
  296 | sort(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _RandomAccessIterator __last);
      | ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:296:1: note:   template argument deduction/substitution failed:
In file included from /usr/include/c++/14/pstl/glue_algorithm_defs.h:15:
/usr/include/c++/14/pstl/execution_defs.h: In substitution of 'template<class _ExecPolicy, class _Tp> using __pstl::__internal::__enable_if_execution_policy = typename std::enable_if<__pstl::execution::v1::is_execution_policy<typename std::remove_cv<typename std::remove_reference<_Tp>::type>::type>::value, _Tp>::type [with _ExecPolicy = __gnu_cxx::__normal_iterator<data_t*, std::vector<data_t> >; _Tp = void]':
/usr/include/c++/14/pstl/glue_algorithm_defs.h:296:1:   required by substitution of 'template<class _ExecutionPolicy, class _RandomAccessIterator> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, void> std::sort(_ExecutionPolicy&&, _RandomAccessIterator, _RandomAccessIterator) [with _ExecutionPolicy = __gnu_cxx::__normal_iterator<data_t*, std::vector<data_t> >; _RandomAccessIterator = __gnu_cxx::__normal_iterator<data_t*, std::vector<data_t> >]'
a.cc:40:7:   required from here
   40 |                 sort(dt.begin(), dt.end(), bcmp);
      |                 ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/pstl/execution_defs.h:82:7: error: no type named 'type' in 'struct std::enable_if<false, void>'
   82 | using __enable_if_execution_policy =
      |       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~