Language: C++

#include <bits/stdc++.h>
using namespace std;

struct data {
  long long a, b;
};
bool operator<(const data &l, const data &r) {
  if(l.a != r.a) return l.a < r.a;
  return l.b > r.b;
}

long long n, t;
vector<data> v;
vector<vector<long long>> dp;

long long solve();

int main() {
  cin >> n >> t;
  v.resize(n);
  for(int i = 0; i < n; ++i) cin >> v[i].a >> v[i].b;
  sort(v.begin(), v.end());
  cout << solve() << endl;
  return 0;
}

long long solve() {
  long long ans = 0;
  dp.assign(n + 1, vector<long long>(t + 1, 0));
  for(int i = 0; i < n; ++i) {
    for(int j = 0; j < t; ++j) {
      dp[i + 1][j] = dp[i][j];
      ans = max(ans, dp[i][j] + v[i].b);
      if(j + v[i].a < t)
        dp[i + 1][j] =
            max(dp[i + 1][j], dp[i][j + v[i].a] + v[i].b);
      ans = max(ans, dp[i + 1][j]);
    }
  }
  return ans;
}


Compiler output:
a.cc:7:22: error: reference to 'data' is ambiguous
    7 | bool operator<(const data &l, const data &r) {
      |                      ^~~~
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:4:8: note:                 'struct data'
    4 | struct data {
      |        ^~~~
a.cc:7:37: error: reference to 'data' is ambiguous
    7 | bool operator<(const data &l, const data &r) {
      |                                     ^~~~
/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:4:8: note:                 'struct data'
    4 | struct data {
      |        ^~~~
a.cc:7:6: error: 'bool operator<(const int&, const int&)' must have an argument of class or enumerated type
    7 | bool operator<(const data &l, const data &r) {
      |      ^~~~~~~~
a.cc:13:12: error: template argument 1 is invalid
   13 | vector<data> v;
      |            ^
a.cc:13:12: error: template argument 2 is invalid
a.cc: In function 'int main()':
a.cc:20:5: error: request for member 'resize' in 'v', which is of non-class type 'int'
   20 |   v.resize(n);
      |     ^~~~~~
a.cc:21:38: error: invalid types 'int[int]' for array subscript
   21 |   for(int i = 0; i < n; ++i) cin >> v[i].a >> v[i].b;
      |                                      ^
a.cc:21:48: error: invalid types 'int[int]' for array subscript
   21 |   for(int i = 0; i < n; ++i) cin >> v[i].a >> v[i].b;
      |                                                ^
a.cc:22:10: error: request for member 'begin' in 'v', which is of non-class type 'int'
   22 |   sort(v.begin(), v.end());
      |          ^~~~~
a.cc:22:21: error: request for member 'end' in 'v', which is of non-class type 'int'
   22 |   sort(v.begin(), v.end());
      |                     ^~~
a.cc: In function 'long long int solve()':
a.cc:33:34: error: invalid types 'int[int]' for array subscript
   33 |       ans = max(ans, dp[i][j] + v[i].b);
      |                                  ^
a.cc:34:15: error: invalid types 'int[int]' for array subscript
   34 |       if(j + v[i].a < t)
      |               ^
a.cc:36:42: error: invalid types 'int[int]' for array subscript
   36 |             max(dp[i + 1][j], dp[i][j + v[i].a] + v[i].b);
      |                                          ^
a.cc:36:52: error: invalid types 'int[int]' for array subscript
   36 |             max(dp[i + 1][j], dp[i][j + v[i].a] + v[i].b);
      |                                                    ^