結果

問題 No.2317 Expression Menu
ユーザー gyozasukisukigyozasukisuki
提出日時 2023-05-26 22:13:46
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 234 ms / 2,000 ms
コード長 1,339 bytes
コンパイル時間 2,094 ms
コンパイル使用メモリ 206,116 KB
実行使用メモリ 228,304 KB
最終ジャッジ日時 2023-08-26 11:57:01
合計ジャッジ時間 11,905 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 161 ms
228,108 KB
testcase_01 AC 159 ms
228,120 KB
testcase_02 AC 162 ms
228,124 KB
testcase_03 AC 224 ms
228,196 KB
testcase_04 AC 226 ms
228,220 KB
testcase_05 AC 228 ms
228,032 KB
testcase_06 AC 223 ms
227,976 KB
testcase_07 AC 228 ms
227,980 KB
testcase_08 AC 224 ms
228,024 KB
testcase_09 AC 219 ms
228,108 KB
testcase_10 AC 229 ms
228,220 KB
testcase_11 AC 226 ms
228,092 KB
testcase_12 AC 228 ms
227,984 KB
testcase_13 AC 223 ms
228,220 KB
testcase_14 AC 234 ms
228,192 KB
testcase_15 AC 223 ms
228,304 KB
testcase_16 AC 224 ms
227,980 KB
testcase_17 AC 230 ms
228,124 KB
testcase_18 AC 226 ms
228,280 KB
testcase_19 AC 234 ms
228,008 KB
testcase_20 AC 231 ms
227,980 KB
testcase_21 AC 221 ms
228,152 KB
testcase_22 AC 224 ms
228,116 KB
testcase_23 AC 225 ms
228,232 KB
testcase_24 AC 221 ms
228,060 KB
testcase_25 AC 221 ms
228,060 KB
testcase_26 AC 223 ms
228,128 KB
testcase_27 AC 221 ms
228,260 KB
testcase_28 AC 221 ms
228,208 KB
testcase_29 AC 226 ms
228,280 KB
testcase_30 AC 222 ms
228,220 KB
testcase_31 AC 221 ms
228,304 KB
testcase_32 AC 219 ms
228,012 KB
testcase_33 AC 161 ms
228,092 KB
testcase_34 AC 160 ms
228,008 KB
testcase_35 AC 159 ms
228,192 KB
testcase_36 AC 160 ms
228,012 KB
testcase_37 AC 161 ms
228,220 KB
testcase_38 AC 200 ms
228,024 KB
testcase_39 AC 208 ms
228,068 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
//#include <atcoder/all>
//using namespace atcoder;
using namespace std;
const int INF = 1e9;
using ll = long long;
using inv = vector<int>;
using stv = vector<string>;
using pint = pair<int,int>;
#define FOR(i,l,r) for(int i=(l); i<(r); i++)
#define rep(i,r) for(int i=0; i<(r); i++)
#define repl(i,r) for(long long i=0; i<(r); i++)
#define FORl(i,l,r) for(long long i=(l); i<(r); i++)
#define INFL ((1LL<<62)-(1LL<<31))
#define pb(x) push_back(x)
#define CIN(x) cin >> x

const ll MOD = 1e9+7;

int N,X,Y;

inv A(305),B(305),C(305);

vector<vector<vector<ll>>> memo(305,vector<vector<ll>>(305,vector<ll>(305,-1LL)));

int main(){
    
    cin >> N >> X >> Y;

    rep(i,N) cin >> A[i] >> B[i] >> C[i];
    memo[0][X][Y] = 0LL;
    // rep(j,X+1) rep(k,Y+1){
    //     memo[0][j][k] = 0;
    // }

    FOR(i,1,N+1){
        rep(j,X+1){
            rep(k,Y+1){
                if(memo[i-1][j][k] == -1) continue;
                
                if(j >= A[i-1] && k >= B[i-1]){
                    memo[i][j-A[i-1]][k-B[i-1]] = max(memo[i][j-A[i-1]][k-B[i-1]],memo[i-1][j][k]+C[i-1]);
                }
                
                memo[i][j][k] = memo[i-1][j][k];
            }
        }

    }

    ll ans = -1LL;

    rep(j,X+1) rep(k,Y+1) ans = max(ans,memo[N][j][k]);
    cout << ans << endl;

    
    
}
0