Language: C++

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
#include<queue>
#define ll long long
#define itn int
#define co(ans) cout<<ans<<endl;
#define COYE cout<<"YES"<<endl;
#define COYe cout<<"Yes"<<endl;
#define COye cout<<"yes"<<endl;
#define CONO cout<<"NO"<<endl;
#define CONo cout<<"No"<<endl;
#define COno cout<<"no"<<endl;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
using namespace std;


int main(){
  int N,T,ans=0;
  cin>>N>>T;
  
  int DP[N+1][T][2];
  // DP[i][j][t] i番目までの食品で時間jまでに食べた時の最大値
  // t==0 特になし  t==1 もう一つ食べる
  
  REP(i,N+1){
    REP(j,T){
      REP(t,2){
        DP[i][j][t]=0;
      }
    }
  }
  
  REP(i,N){
    ll a,b;
    cin>>a>>b;
    REP(j,T){
      DP[i+1][j][0]=DP[i][j][0];
      DP[i+1][j][1]=max(DP[i][j][1],DP[i][j][0]+b);
      if(j>=a){
        chmax(DP[i+1][j][0],DP[i][j-a][0]+b);
        chmax(DP[i+1][j][1],DP[i][j-a][1]+b);
      }
    }
  }
  
  
  co(max(DP[N][T-1][0],DP[N][T-1][1]));
}

Compiler output:
a.cc: In function 'int main()':
a.cc:52:24: error: no matching function for call to 'max(int&, long long int)'
   52 |       DP[i+1][j][1]=max(DP[i][j][1],DP[i][j][0]+b);
      |                     ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/string:51,
                 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: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:52:24: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   52 |       DP[i+1][j][1]=max(DP[i][j][1],DP[i][j][0]+b);
      |                     ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
/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,
                 from a.cc:4:
/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:52:24: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   52 |       DP[i+1][j][1]=max(DP[i][j][1],DP[i][j][0]+b);
      |                     ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:54:14: error: no matching function for call to 'chmax(int&, long long int)'
   54 |         chmax(DP[i+1][j][0],DP[i][j-a][0]+b);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:26:23: note: candidate: 'template<class T> bool chmax(T&, const T&)'
   26 | template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
      |                       ^~~~~
a.cc:26:23: note:   template argument deduction/substitution failed:
a.cc:54:14: note:   deduced conflicting types for parameter 'const T' ('int' and 'long long int')
   54 |         chmax(DP[i+1][j][0],DP[i][j-a][0]+b);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:55:14: error: no matching function for call to 'chmax(int&, long long int)'
   55 |         chmax(DP[i+1][j][1],DP[i][j-a][1]+b);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:26:23: note: candidate: 'template<class T> bool chmax(T&, const T&)'
   26 | template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
      |                       ^~~~~
a.cc:26:23: note:   template argument deduction/substitution failed:
a.cc:55:14: note:   deduced conflicting types for parameter 'const T' ('int' and 'long long int')
   55 |         chmax(DP[i+1][j][1],DP[i][j-a][1]+b);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~