結果

問題 No.2317 Expression Menu
ユーザー Pon9078Pon9078
提出日時 2023-05-26 22:59:59
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 222 ms / 2,000 ms
コード長 1,761 bytes
コンパイル時間 733 ms
コンパイル使用メモリ 87,784 KB
実行使用メモリ 220,068 KB
最終ジャッジ日時 2023-08-26 13:22:11
合計ジャッジ時間 9,229 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 15 ms
18,912 KB
testcase_03 AC 213 ms
219,588 KB
testcase_04 AC 214 ms
219,456 KB
testcase_05 AC 213 ms
219,572 KB
testcase_06 AC 213 ms
219,480 KB
testcase_07 AC 214 ms
219,448 KB
testcase_08 AC 212 ms
220,048 KB
testcase_09 AC 211 ms
219,580 KB
testcase_10 AC 213 ms
219,636 KB
testcase_11 AC 214 ms
219,500 KB
testcase_12 AC 216 ms
219,644 KB
testcase_13 AC 216 ms
219,444 KB
testcase_14 AC 213 ms
219,448 KB
testcase_15 AC 213 ms
219,632 KB
testcase_16 AC 215 ms
219,528 KB
testcase_17 AC 216 ms
219,476 KB
testcase_18 AC 216 ms
219,636 KB
testcase_19 AC 214 ms
219,524 KB
testcase_20 AC 216 ms
219,532 KB
testcase_21 AC 220 ms
219,524 KB
testcase_22 AC 219 ms
219,452 KB
testcase_23 AC 221 ms
219,468 KB
testcase_24 AC 219 ms
219,472 KB
testcase_25 AC 220 ms
219,628 KB
testcase_26 AC 222 ms
219,472 KB
testcase_27 AC 220 ms
219,448 KB
testcase_28 AC 221 ms
219,636 KB
testcase_29 AC 222 ms
219,636 KB
testcase_30 AC 221 ms
219,580 KB
testcase_31 AC 216 ms
220,068 KB
testcase_32 AC 219 ms
219,524 KB
testcase_33 AC 2 ms
4,380 KB
testcase_34 AC 1 ms
4,380 KB
testcase_35 AC 3 ms
5,080 KB
testcase_36 AC 2 ms
4,380 KB
testcase_37 AC 2 ms
4,380 KB
testcase_38 AC 219 ms
219,456 KB
testcase_39 AC 216 ms
219,536 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<set>

using namespace std;
typedef long long ll;
#define loop1(n) for(int loopt = 0; loopt < (n); loopt++)
#define loop2(i,n) for((i) = 0; (i) < (n); (i)++)
#define loop3(i,k,n) for((i) = (k); (i) < (n); (i)++)
#define GET_NAME_LOOP(_2,_3,NAME,...) NAME
#define loop(n,...) GET_NAME_LOOP(__VA_ARGS__,loop3,loop2,loop1)(n,__VA_ARGS__)

#define rloop1(n) for(int loopt = (n)-1; loopt >= 0; loopt--)
#define rloop2(i,n) for((i) = (n)-1; (i) >= 0; (i)--)
#define rloop3(i,k,n) for((i) = (k)-1; (i) >= (n); (i)--)
#define GET_NAME_RLOOP(_2,_3,NAME,...) NAME
#define rloop(n,...) GET_NAME_RLOOP(__VA_ARGS__,rloop3,rloop2,rloop1)(n,__VA_ARGS__)

#define outone cout << "First" << endl
#define outtwo cout << "Second" << endl
#define outyes cout << "Yes" << endl
#define outno cout << "No" << endl
#define outans cout << ans << endl
#define all(i) i.begin(),i.end()
//const ll mod =  998244353L;
//const ll mod = 1e9+7L;
//const double PI =3.14159265359d;
//const double E =2.718281828d;

int main() {
    int n,x,y;
    cin >> n >> x >> y;
    vector<vector<vector<ll>>> dp(n+1,vector<vector<ll>> (x+1,vector<ll>(y+1,0)));
    int i,j,k;
    loop(i,0,n){
        int a,b;
        ll c;
        cin >>a >> b >> c;
        loop(j,0,x+1){
            loop(k,0,y+1){
                dp[i+1][j][k] = max(dp[i+1][j][k],dp[i][j][k]);
                if(j+a <x+1 && k+b < y+1){
                    dp[i+1][j+a][k+b] = max(dp[i+1][j+a][k+b],dp[i][j][k]+c);
                }
            }
        }
    }

    ll ans = 0;
    loop(i,0,x+1){
        loop(j,0,y+1){
            ans = max(ans,dp[n][i][j]);
        }
    }
    outans;
}
0