結果

問題 No.2317 Expression Menu
ユーザー tnakao0123tnakao0123
提出日時 2023-06-23 18:02:16
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 31 ms / 2,000 ms
コード長 996 bytes
コンパイル時間 267 ms
コンパイル使用メモリ 42,660 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-13 12:55:27
合計ジャッジ時間 3,003 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 11 ms
4,376 KB
testcase_04 AC 10 ms
4,376 KB
testcase_05 AC 13 ms
4,376 KB
testcase_06 AC 11 ms
4,376 KB
testcase_07 AC 12 ms
4,380 KB
testcase_08 AC 11 ms
4,376 KB
testcase_09 AC 13 ms
4,380 KB
testcase_10 AC 13 ms
4,376 KB
testcase_11 AC 14 ms
4,376 KB
testcase_12 AC 14 ms
4,376 KB
testcase_13 AC 12 ms
4,380 KB
testcase_14 AC 17 ms
4,376 KB
testcase_15 AC 12 ms
4,376 KB
testcase_16 AC 13 ms
4,380 KB
testcase_17 AC 14 ms
4,376 KB
testcase_18 AC 12 ms
4,380 KB
testcase_19 AC 15 ms
4,380 KB
testcase_20 AC 15 ms
4,376 KB
testcase_21 AC 11 ms
4,376 KB
testcase_22 AC 12 ms
4,380 KB
testcase_23 AC 31 ms
4,376 KB
testcase_24 AC 31 ms
4,380 KB
testcase_25 AC 31 ms
4,376 KB
testcase_26 AC 30 ms
4,380 KB
testcase_27 AC 30 ms
4,384 KB
testcase_28 AC 30 ms
4,380 KB
testcase_29 AC 31 ms
4,380 KB
testcase_30 AC 30 ms
4,376 KB
testcase_31 AC 30 ms
4,380 KB
testcase_32 AC 30 ms
4,380 KB
testcase_33 AC 1 ms
4,380 KB
testcase_34 AC 2 ms
4,376 KB
testcase_35 AC 2 ms
4,376 KB
testcase_36 AC 1 ms
4,376 KB
testcase_37 AC 2 ms
4,376 KB
testcase_38 AC 24 ms
4,376 KB
testcase_39 AC 24 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

/* -*- coding: utf-8 -*-
 *
 * 2317.cc:  No.2317 Expression Menu - yukicoder
 */

#include<cstdio>
#include<algorithm>
 
using namespace std;

/* constant */

const int MAX_N = 300;
const int MAX_X = 300;
const int MAX_Y = 300;

/* typedef */

typedef long long ll;

/* global variables */

int as[MAX_N], bs[MAX_N], cs[MAX_N];
ll dp[MAX_X + 1][MAX_Y + 1];

/* subroutines */

inline void setmax(ll &a, ll b) { if (a < b) a = b; }

/* main */

int main() {
  int n, x, y;
  scanf("%d%d%d", &n, &x, &y);
  for (int i = 0; i < n; i++) scanf("%d%d%d", as + i, bs + i, cs + i);

  for (int i = 0; i <= x; i++) fill(dp[i], dp[i] + y + 1, -1);
  dp[0][0] = 0;

  for (int i = 0; i < n; i++)
    for (int j = x - as[i]; j >= 0; j--)
      for (int k = y - bs[i]; k >= 0; k--)
	if (dp[j][k] >= 0)
	  setmax(dp[j + as[i]][k + bs[i]], dp[j][k] + cs[i]);

  ll maxd = 0;
  for (int j = 0; j <= x; j++)
    for (int k = 0; k <= y; k++)
      setmax(maxd, dp[j][k]);

  printf("%lld\n", maxd);

  return 0;
}
0