結果

問題 No.2317 Expression Menu
ユーザー kusaf_kusaf_
提出日時 2023-05-27 20:39:11
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 254 ms / 2,000 ms
コード長 923 bytes
コンパイル時間 2,253 ms
コンパイル使用メモリ 205,148 KB
実行使用メモリ 219,996 KB
最終ジャッジ日時 2023-08-27 00:03:25
合計ジャッジ時間 12,958 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,384 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 19 ms
18,948 KB
testcase_03 AC 238 ms
219,824 KB
testcase_04 AC 238 ms
219,820 KB
testcase_05 AC 235 ms
219,824 KB
testcase_06 AC 236 ms
219,860 KB
testcase_07 AC 236 ms
219,996 KB
testcase_08 AC 236 ms
219,716 KB
testcase_09 AC 236 ms
219,820 KB
testcase_10 AC 234 ms
219,824 KB
testcase_11 AC 239 ms
219,836 KB
testcase_12 AC 237 ms
219,916 KB
testcase_13 AC 238 ms
219,724 KB
testcase_14 AC 239 ms
219,860 KB
testcase_15 AC 236 ms
219,772 KB
testcase_16 AC 237 ms
219,820 KB
testcase_17 AC 239 ms
219,816 KB
testcase_18 AC 236 ms
219,716 KB
testcase_19 AC 237 ms
219,812 KB
testcase_20 AC 238 ms
219,856 KB
testcase_21 AC 236 ms
219,716 KB
testcase_22 AC 238 ms
219,816 KB
testcase_23 AC 252 ms
219,860 KB
testcase_24 AC 251 ms
219,728 KB
testcase_25 AC 250 ms
219,824 KB
testcase_26 AC 251 ms
219,764 KB
testcase_27 AC 251 ms
219,820 KB
testcase_28 AC 250 ms
219,808 KB
testcase_29 AC 252 ms
219,916 KB
testcase_30 AC 254 ms
219,720 KB
testcase_31 AC 251 ms
219,860 KB
testcase_32 AC 252 ms
219,816 KB
testcase_33 AC 2 ms
4,380 KB
testcase_34 AC 2 ms
4,376 KB
testcase_35 AC 4 ms
5,252 KB
testcase_36 AC 1 ms
4,376 KB
testcase_37 AC 2 ms
4,376 KB
testcase_38 AC 254 ms
219,816 KB
testcase_39 AC 252 ms
219,812 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

template<typename T, typename U> bool chmax(T &a, const U &b) {
  if(a < b) {
    a = b;
    return 1;
  }
  return 0;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n, x, y;
  cin >> n >> x >> y;
  vector<vector<ll>> v(n, vector<ll>(3));
  for(ll i = 0; i < n; i++)
    for(ll j = 0; j < 3; j++) cin >> v[i][j];
  vector<vector<vector<ll>>> dp(n + 1, vector<vector<ll>>(x + 1, vector<ll>(y + 1, 0)));
  for(ll i = 0; i < n; i++) {
    for(ll j = 0; j <= x; j++) {
      for(ll k = 0; k <= y; k++) {
        chmax(dp[i + 1][j][k], dp[i][j][k]);
        if(j + v[i][0] > x || k + v[i][1] > y) continue;
        chmax(dp[i + 1][j + v[i][0]][k + v[i][1]], dp[i][j][k] + v[i][2]);
      }
    }
  }
  ll r = 0;
  for(ll i = 0; i <= x; i++) {
    for(ll j = 0; j <= y; j++) {
      r = max(r, dp[n][i][j]);
    }
  }
  cout << r << "\n";
}
0