結果

問題 No.2317 Expression Menu
ユーザー unibop
提出日時 2023-05-31 23:48:34
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 233 ms / 2,000 ms
コード長 1,045 bytes
コンパイル時間 3,314 ms
コンパイル使用メモリ 170,644 KB
最終ジャッジ日時 2025-02-13 17:11:28
ジャッジサーバーID
(参考情報)
judge1 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 37
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <iomanip>
#include <stack>
#include <queue>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <bitset>
#include <atcoder/all>
#define rep(i,n) for(int i = 0; i < n; i++)

using namespace std;
using namespace atcoder;
using ll = long long;

long long dp[301][301][301];
int main() {
    int n, x, y;
    cin >> n >> x >> y;

    for (int i = 1; i <= n; i++) {
        int a, b;
        long long c;
        cin >> a >> b >> c;
        for (int j = 1; j <= x; j++) {
            for (int k = 1; k <= y; k++) {
                dp[i][j][k] = dp[i - 1][j][k];
                if (j - a >= 0 && k - b >= 0) {
                    dp[i][j][k] = max(dp[i][j][k], dp[i - 1][j - a][k - b] + c);
                }
            }
        }
    }
    
    long long ans = 0;
    for (int j = 0; j <= x; j++) {
        for (int k = 0; k <= y; k++) {
            ans = max(ans, dp[n][j][k]);
        }
    }
    
    cout << ans << endl;
    return 0;
}
0