Language: C++

#include <bits/stdc++.h>
#define FOR(i,k,n) for(int i=(k);i<(int)(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;

int main() {
  int64_t n;
  cin>>n;
  using T = tuple<int64_t,int64_t,int64_t,int64_t>;
  vector<T> vc;
  int64_t h0,a0,d0,s0;
  cin>>h0>>a0>>d0>>s0;
  REP(i,n) {
    int64_t h,a,d,s;
    cin>>h>>a>>d>>s;
    vc.emplace_back(max(a-d0,0),s,max(0,a0-d),h);
  }
  sort(ALL(vc),greater<T>());
  int64_t turns = 0;
  bool imp = false;
  int64_t damage = 0;
  for (T t:vc) {
    int64_t d,s,a,h;
    tie(d,s,a,h) = t;
    if (a == 0 && d != 0) {
      imp = true;
      break;
    } else {
      turns += (h + a-1) / a;
      if (s < s0) {
        damage += (turns-1) * d;
      } else {
        damage += turns * d;
      }
    }
  }
  if (imp || damage >= h0) {
    cout << -1 << endl;
  } else {
    cout << damage << endl;
  }
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:18:24: error: no matching function for call to 'max(int64_t, int)'
   18 |     vc.emplace_back(max(a-d0,0),s,max(0,a0-d),h);
      |                     ~~~^~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:18:24: note:   deduced conflicting types for parameter 'const _Tp' ('long int' and 'int')
   18 |     vc.emplace_back(max(a-d0,0),s,max(0,a0-d),h);
      |                     ~~~^~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:18:24: note:   mismatched types 'std::initializer_list<_Tp>' and 'long int'
   18 |     vc.emplace_back(max(a-d0,0),s,max(0,a0-d),h);
      |                     ~~~^~~~~~~~
a.cc:18:38: error: no matching function for call to 'max(int, int64_t)'
   18 |     vc.emplace_back(max(a-d0,0),s,max(0,a0-d),h);
      |                                   ~~~^~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:18:38: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'int64_t' {aka 'long int'})
   18 |     vc.emplace_back(max(a-d0,0),s,max(0,a0-d),h);
      |                                   ~~~^~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:18:38: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   18 |     vc.emplace_back(max(a-d0,0),s,max(0,a0-d),h);
      |                                   ~~~^~~~~~~~