結果

問題 No.2317 Expression Menu
ユーザー planes
提出日時 2023-05-26 21:37:39
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 240 ms / 2,000 ms
コード長 699 bytes
コンパイル時間 1,578 ms
コンパイル使用メモリ 174,748 KB
実行使用メモリ 220,032 KB
最終ジャッジ日時 2024-12-25 05:35:36
合計ジャッジ時間 9,683 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 37
権限があれば一括ダウンロードができます

ソースコード

diff #

  #include <bits/stdc++.h> 
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 #define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)

ll INF=2e18;


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

ll N,X,Y;cin>>N>>X>>Y;
vector<ll> A(N),B(N),C(N);
for(ll i=0;i<N;i++) cin>>A[i]>>B[i]>>C[i];

vector<vector<vector<ll>>> dp(N+1,vector<vector<ll>> (X+1,vector<ll>(Y+1,0)));

for(ll i=1;i<=N;i++) {
  for(ll x=0;x<=X;x++) {
    for(ll y=0;y<=Y;y++) {
      dp[i][x][y]=dp[i-1][x][y];
      if(x>=A[i-1]&&y>=B[i-1]) {
        dp[i][x][y]=max(dp[i][x][y],dp[i-1][x-A[i-1]][y-B[i-1]]+C[i-1]);
      }
    }
  }
}

cout<<dp[N][X][Y]<<endl;
}
0