結果

問題 No.2317 Expression Menu
ユーザー GlinTFrauleinGlinTFraulein
提出日時 2023-05-26 23:12:51
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 396 ms / 2,000 ms
コード長 1,205 bytes
コンパイル時間 3,947 ms
コンパイル使用メモリ 263,100 KB
実行使用メモリ 370,596 KB
最終ジャッジ日時 2023-08-26 13:38:32
合計ジャッジ時間 17,641 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6 ms
9,176 KB
testcase_01 AC 6 ms
9,148 KB
testcase_02 AC 28 ms
29,760 KB
testcase_03 AC 391 ms
370,424 KB
testcase_04 AC 378 ms
370,596 KB
testcase_05 AC 377 ms
370,304 KB
testcase_06 AC 376 ms
370,308 KB
testcase_07 AC 378 ms
370,260 KB
testcase_08 AC 379 ms
370,352 KB
testcase_09 AC 381 ms
370,248 KB
testcase_10 AC 377 ms
370,308 KB
testcase_11 AC 379 ms
370,248 KB
testcase_12 AC 379 ms
370,252 KB
testcase_13 AC 377 ms
370,372 KB
testcase_14 AC 380 ms
370,244 KB
testcase_15 AC 379 ms
370,428 KB
testcase_16 AC 381 ms
370,592 KB
testcase_17 AC 380 ms
370,368 KB
testcase_18 AC 380 ms
370,348 KB
testcase_19 AC 378 ms
370,252 KB
testcase_20 AC 377 ms
370,588 KB
testcase_21 AC 378 ms
370,248 KB
testcase_22 AC 378 ms
370,332 KB
testcase_23 AC 393 ms
370,352 KB
testcase_24 AC 396 ms
370,304 KB
testcase_25 AC 394 ms
370,580 KB
testcase_26 AC 392 ms
370,564 KB
testcase_27 AC 394 ms
370,436 KB
testcase_28 AC 393 ms
370,436 KB
testcase_29 AC 390 ms
370,436 KB
testcase_30 AC 391 ms
370,360 KB
testcase_31 AC 392 ms
370,432 KB
testcase_32 AC 394 ms
370,304 KB
testcase_33 AC 4 ms
6,828 KB
testcase_34 AC 4 ms
6,728 KB
testcase_35 AC 4 ms
6,732 KB
testcase_36 AC 3 ms
6,716 KB
testcase_37 AC 4 ms
6,728 KB
testcase_38 AC 389 ms
370,308 KB
testcase_39 AC 389 ms
370,304 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
 
#define elif else if
#define ll long long
#define vll vector<long long>
#define vec vector
#define embk emplace_back
#define rep(i, n) for (ll i = 0; i < n; i++)
#define rep3(i, n, k) for (ll i = k; i < n; i++)
#define all(a) a.begin(), a.end()
#define YNeos(bool) (bool ? "Yes" : "No")
 
using namespace std;
using namespace atcoder;
const ll INF = 1LL << 60;
const ll mod = 998244353;
const double pi = acos(-1);

int main() {
  ll n, x, y; cin >> n >> x >> y;
  vll a(n), b(n), c(n); rep(i, n) cin >> a[i] >> b[i] >> c[i];

  const ll xpr = 500;

  vec<vll> dp(n+1, vll(155310));  //dp[i番目の機能まで見た][消費したメニュー枠*1000+消費した容量]=上げたかわいさの最大値
  dp[0][0] = 0;

  rep(i, n) {
    ll abadd = a[i]*xpr+b[i];
    rep(j, x) {
      rep(k, y) {
        ll itr = j*xpr+k;
        dp[i+1][itr] = max(dp[i][itr], dp[i+1][itr]);
        if (((itr/xpr + abadd/xpr) <= x) && ((itr%xpr + abadd%xpr) <= y)) dp[i+1][itr+abadd] = max(dp[i][itr]+c[i], dp[i+1][itr+abadd]);
      }
    }
  }

  ll ans = 0;
  rep(i, n+1) {
    rep(j, 155310) {
      ans = max(dp[i][j], ans);
    }
  }

  cout << ans << endl;
}
0