Language: C++

#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <vector>
using namespace std;

struct data {
	int turn, damage, idx;
	data(int t, int d, int i):turn(t), damage(d), idx(i){}

	bool operator<(const data& d) const {
		return (double)damage / turn < (double)d.damage / d.turn;
	}
};

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int n;
	cin >> n;

	vector<int> h(n + 1), a(n + 1), d(n + 1), s(n + 1);
	for(int i = 0; i < n + 1; ++i)
		cin >> h[i] >> a[i] >> d[i] >> s[i];

	vector<data> dat;
	dat.reserve(n);
	for(int i = 1; i < n + 1; ++i) {
		const int attack = max(0, a[0] - d[i]);
		if(!attack) {
			cout << -1 << endl;
			return EXIT_SUCCESS;
		}

		const int turn = ceil((double)h[i] / attack);
		const int damage = a[i] - d[0];
		dat.push_back(data(turn, damage, i));
	}

	sort(dat.rbegin(), dat.rend());
	long long turn = 0, hp = h[0];
	for(int i = 0; i < n; ++i) {
		turn += dat[i].turn;
		hp -= dat[i].damage * (turn - (s[0] > s[dat[i].idx] ? 1 : 0));
		if(hp <= 0) {
			cout << -1 << endl;
			return EXIT_SUCCESS;
		}
	}

	cout << h[0] - hp << endl;

	return EXIT_SUCCESS;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:27:20: error: template argument 1 is invalid
   27 |         vector<data> dat;
      |                    ^
a.cc:27:20: error: template argument 2 is invalid
a.cc:28:13: error: request for member 'reserve' in 'dat', which is of non-class type 'int'
   28 |         dat.reserve(n);
      |             ^~~~~~~
a.cc:36:34: error: 'ceil' was not declared in this scope
   36 |                 const int turn = ceil((double)h[i] / attack);
      |                                  ^~~~
a.cc:38:21: error: request for member 'push_back' in 'dat', which is of non-class type 'int'
   38 |                 dat.push_back(data(turn, damage, i));
      |                     ^~~~~~~~~
a.cc:38:31: error: reference to 'data' is ambiguous
   38 |                 dat.push_back(data(turn, damage, i));
      |                               ^~~~
In file included from /usr/include/c++/14/string:53,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:3:
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:7:8: note:                 'struct data'
    7 | struct data {
      |        ^~~~
a.cc:41:18: error: request for member 'rbegin' in 'dat', which is of non-class type 'int'
   41 |         sort(dat.rbegin(), dat.rend());
      |                  ^~~~~~
a.cc:41:32: error: request for member 'rend' in 'dat', which is of non-class type 'int'
   41 |         sort(dat.rbegin(), dat.rend());
      |                                ^~~~
a.cc:44:28: error: invalid types 'int[int]' for array subscript
   44 |                 turn += dat[i].turn;
      |                            ^
a.cc:45:26: error: invalid types 'int[int]' for array subscript
   45 |                 hp -= dat[i].damage * (turn - (s[0] > s[dat[i].idx] ? 1 : 0));
      |                          ^
a.cc:45:60: error: invalid types 'int[int]' for array subscript
   45 |                 hp -= dat[i].damage * (turn - (s[0] > s[dat[i].idx] ? 1 : 0));
      |                                                            ^