結果

問題 No.2317 Expression Menu
ユーザー nagisa5101nagisa5101
提出日時 2023-05-26 21:36:26
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 311 ms / 2,000 ms
コード長 1,467 bytes
コンパイル時間 3,987 ms
コンパイル使用メモリ 261,488 KB
実行使用メモリ 216,680 KB
最終ジャッジ日時 2023-08-26 10:39:06
合計ジャッジ時間 13,016 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 51 ms
216,520 KB
testcase_01 AC 51 ms
216,460 KB
testcase_02 AC 51 ms
216,456 KB
testcase_03 AC 192 ms
216,488 KB
testcase_04 AC 192 ms
216,584 KB
testcase_05 AC 252 ms
216,476 KB
testcase_06 AC 171 ms
216,484 KB
testcase_07 AC 245 ms
216,508 KB
testcase_08 AC 180 ms
216,552 KB
testcase_09 AC 197 ms
216,500 KB
testcase_10 AC 225 ms
216,480 KB
testcase_11 AC 239 ms
216,476 KB
testcase_12 AC 241 ms
216,620 KB
testcase_13 AC 217 ms
216,492 KB
testcase_14 AC 311 ms
216,480 KB
testcase_15 AC 180 ms
216,472 KB
testcase_16 AC 237 ms
216,484 KB
testcase_17 AC 283 ms
216,680 KB
testcase_18 AC 176 ms
216,484 KB
testcase_19 AC 279 ms
216,472 KB
testcase_20 AC 276 ms
216,488 KB
testcase_21 AC 173 ms
216,480 KB
testcase_22 AC 176 ms
216,616 KB
testcase_23 AC 276 ms
216,488 KB
testcase_24 AC 243 ms
216,616 KB
testcase_25 AC 230 ms
216,548 KB
testcase_26 AC 228 ms
216,548 KB
testcase_27 AC 227 ms
216,556 KB
testcase_28 AC 250 ms
216,680 KB
testcase_29 AC 265 ms
216,680 KB
testcase_30 AC 257 ms
216,520 KB
testcase_31 AC 236 ms
216,496 KB
testcase_32 AC 234 ms
216,560 KB
testcase_33 AC 50 ms
216,460 KB
testcase_34 AC 52 ms
216,500 KB
testcase_35 AC 52 ms
216,508 KB
testcase_36 AC 52 ms
216,596 KB
testcase_37 AC 52 ms
216,464 KB
testcase_38 AC 53 ms
216,568 KB
testcase_39 AC 54 ms
216,496 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

using namespace std;
using namespace atcoder;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repll(i, n) for (long long i = 0; i < (long long)(n); i++)
#define rep2(i, n, m) for (int i = n; i < (int)(m); i++)
#define repll2(i, n, m) for (long long i = n; i < (long long)(m); i++)
#define all(v) v.begin(),v.end()
using ll=long long;
using ld=long double;
using vi=vector<int>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vvvl=vector<vvl>;
using vld=vector<ld>;
using vvld=vector<vld>;

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,1,-1};

const double PI = acos(-1);
//const ll MOD=1e9+7;
//const ll MOD=998244353;
const ll INF=(1LL<<60);
const int INF2=(1<<30);
//using mint=modint1000000007;
//using mint=modint998244353;

ll memo[301][301][301];
ll A[300],B[300],C[300];
int n;

ll dp(int i,int j,int k){
    if(memo[i][j][k]!=-1)return memo[i][j][k];
    if(j==0||k==0)return 0;
    if(i==n)return 0;
    ll ans=dp(i+1,j,k);
    if(j>=A[i]&&k>=B[i])ans=max(ans,dp(i+1,j-A[i],k-B[i])+C[i]);
    memo[i][j][k]=ans;
    return ans;
}



int main() {
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int x,y;cin>>n>>x>>y;
    memset(memo,-1,sizeof(memo));
    rep(i,n)cin>>A[i]>>B[i]>>C[i];
    cout<<dp(0,x,y)<<endl;
    return 0;
}
0