Language: C++

#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define svec(v) cout<<#v<<":";rep(kbrni,v.size())cout<<" "<<v[kbrni];cout<<endl
#define sset(s) cout<<#s<<":";each(kbrni,s)cout<<" "<<kbrni;cout<<endl
#define smap(m) cout<<#m<<":";each(kbrni,m)cout<<" {"<<kbrni.first<<":"<<kbrni.second<<"}";cout<<endl
#define int long long

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 100005;

struct data
{
    int h,a,d,s,u,v;
};

vector<data> vec;
data zibun;

bool possible(int cri)
{
    int tm = 0;
    int al = 0;
    rep(i,len(vec)){
        // cout << vec[i].h << " " << vec[i].a << " " << vec[i].d << " " << vec[i].s << " " << vec[i].u << " " << vec[i].v << "\n";
        if(zibun.s < vec[i].s){
            tm += vec[i].v - 1;
            al += tm*vec[i].u;
            if(al > cri){
                return false;
            }
        }else{
            tm += vec[i].v;
            al += tm*vec[i].u;
            if(al > cri){
                return false;
            }
        }
    }
    return true;
}

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    rep(i,n+1){
        int w,x,y,z;
        cin >> w >> x >> y >> z;
        if(i == 0){
            zibun = (data){w,x,y,z,0LL,0LL};
        }else{
            if(zibun.a <= y){
                if(zibun.d < x){
                    cout << "-1\n";
                    return 0;
                }else{
                    continue;
                }
            }
            vec.pb((data){w,x,y,z,max(x-zibun.d,0LL),floor((double)(w-0.5)/(zibun.a-y))+1LL});
        }
    }
    sort(all(vec),[&](const data& x,const data& y){
        return y.u*x.v > x.u*y.v;
    });
    int l = 0,r = zibun.h;
    if(!possible(r)){
        cout << "-1\n";
        return 0;
    }
    while(r-l>1){
        int mid = (l+r)/2;
        if(possible(mid)){
            r = mid;
        }else{
            l = mid;
        }
    }
    cout << r << "\n";
    return 0;
}

Compiler output:
a.cc:44:12: error: template argument 1 is invalid
   44 | vector<data> vec;
      |            ^
a.cc:44:12: error: template argument 2 is invalid
a.cc:45:1: error: reference to 'data' is ambiguous
   45 | data zibun;
      | ^~~~
In file included from /usr/include/c++/14/string:53,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 from a.cc:1:
/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:39:8: note:                 'struct data'
   39 | struct data
      |        ^~~~
a.cc: In function 'bool possible(long long int)':
a.cc:11:25: error: request for member 'size' in 'vec', which is of non-class type 'int'
   11 | #define len(v) (int)(v).size()
      |                         ^~~~
a.cc:6:38: note: in definition of macro 'rep'
    6 | #define rep(i,n) for(int i=0;i<(int)(n);++i)
      |                                      ^
a.cc:51:11: note: in expansion of macro 'len'
   51 |     rep(i,len(vec)){
      |           ^~~
a.cc:53:12: error: 'zibun' was not declared in this scope
   53 |         if(zibun.s < vec[i].s){
      |            ^~~~~
a.cc:53:25: error: invalid types 'int[long long int]' for array subscript
   53 |         if(zibun.s < vec[i].s){
      |                         ^
a.cc:54:22: error: invalid types 'int[long long int]' for array subscript
   54 |             tm += vec[i].v - 1;
      |                      ^
a.cc:55:25: error: invalid types 'int[long long int]' for array subscript
   55 |             al += tm*vec[i].u;
      |                         ^
a.cc:60:22: error: invalid types 'int[long long int]' for array subscript
   60 |             tm += vec[i].v;
      |                      ^
a.cc:61:25: error: invalid types 'int[long long int]' for array subscript
   61 |             al += tm*vec[i].u;
      |                         ^
a.cc: In function 'int main()':
a.cc:80:13: error: 'zibun' was not declared in this scope
   80 |             zibun = (data){w,x,y,z,0LL,0LL};
      |             ^~~~~
a.cc:80:22: error: reference to 'data' is ambiguous
   80 |             zibun = (data){w,x,y,z,0LL,0LL};
      |                      ^~~~
/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:39:8: note:                 'struct data'
   39 | struct data
      |        ^~~~
a.cc:82:16: error: 'zibun' was not declared in this scope
   82 |             if(zibun.a <= y){
      |                ^~~~~
a.cc:17:12: error: request for member 'push_back' in 'vec', which is of non-class type 'int'
   17 | #define pb push_back
      |            ^~~~~~~~~
a.cc:90:17: note: in expansion of macro 'pb'
   90 |             vec.pb((data){w,x,y,z,max(x-zibun.d,0LL),floor((double)(w-0.5)/(zibun.a-y))+1LL});
      |                 ^~
a.cc:90:21: error: reference to 'data' is ambiguous
   90 |             vec.pb((data){w,x,y,z,max(x-zibun.d,0LL),floor((double)(w-0.5)/(zibun.a-y))+1LL});
      |                     ^~~~
/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:39:8: note:                 'struct data'
   39 | struct data
      |        ^~~~
a.cc:10:20: error: request for member 'begin' in 'vec', which is of non-class type 'int'
   10 | #define all(v) (v).begin(),(v).end()
      |                    ^~~~~
a.cc:93:10: note: in expansion of macro 'all'
   93 |     sort(all(vec),[&](const data& x,const data& y){
      |          ^~~
a.cc:10:32: error: request for member 'end' in 'vec', which is of non-class type 'int'
   10 | #define all(v) (v).begin(),(v).end()
      |                                ^~~
a.cc:93:10: note: in expansion of macro 'all'
   93 |     sort(all(vec),[&](const data& x,const data& y){
      |          ^~~
a.cc:93:29: error: reference to 'data' is ambiguous
   93 |     sort(all(vec),[&](const data& x,const data& y){
      |                             ^~~~
/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:39:8: note:                 'struct data'
   39 | struct data
      |        ^~~~
a.cc: In lambda function:
a.cc:95:7: error: expected '{' before ';' token
   95 |     });
      |       ^
a.cc: In function 'int main()':
a.cc:95:7: error: expected ')' before ';' token
   95 |     });
      |       ^
      |       )
a.cc:93:9: note: to match this '('
   93 |     sort(all(vec),[&](const data& x,const data& y){
      |         ^
a.cc:96:19: error: 'zibun' was not declared in this scope
   96 |     int l = 0,r = zibun.h;
      |                   ^~~~~