結果

問題 No.2317 Expression Menu
ユーザー outlineoutline
提出日時 2023-06-14 20:26:09
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 107 ms / 2,000 ms
コード長 2,004 bytes
コンパイル時間 1,564 ms
コンパイル使用メモリ 145,040 KB
実行使用メモリ 4,752 KB
最終ジャッジ日時 2023-09-05 06:35:36
合計ジャッジ時間 6,598 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 8 ms
4,484 KB
testcase_03 AC 80 ms
4,480 KB
testcase_04 AC 78 ms
4,640 KB
testcase_05 AC 81 ms
4,516 KB
testcase_06 AC 80 ms
4,620 KB
testcase_07 AC 80 ms
4,604 KB
testcase_08 AC 79 ms
4,464 KB
testcase_09 AC 81 ms
4,536 KB
testcase_10 AC 80 ms
4,752 KB
testcase_11 AC 82 ms
4,476 KB
testcase_12 AC 82 ms
4,636 KB
testcase_13 AC 80 ms
4,460 KB
testcase_14 AC 84 ms
4,468 KB
testcase_15 AC 80 ms
4,668 KB
testcase_16 AC 82 ms
4,512 KB
testcase_17 AC 81 ms
4,612 KB
testcase_18 AC 79 ms
4,520 KB
testcase_19 AC 84 ms
4,468 KB
testcase_20 AC 84 ms
4,476 KB
testcase_21 AC 82 ms
4,672 KB
testcase_22 AC 80 ms
4,524 KB
testcase_23 AC 107 ms
4,516 KB
testcase_24 AC 105 ms
4,504 KB
testcase_25 AC 105 ms
4,588 KB
testcase_26 AC 105 ms
4,516 KB
testcase_27 AC 106 ms
4,520 KB
testcase_28 AC 105 ms
4,520 KB
testcase_29 AC 107 ms
4,724 KB
testcase_30 AC 106 ms
4,592 KB
testcase_31 AC 106 ms
4,640 KB
testcase_32 AC 104 ms
4,672 KB
testcase_33 AC 1 ms
4,376 KB
testcase_34 AC 2 ms
4,384 KB
testcase_35 AC 3 ms
4,380 KB
testcase_36 AC 2 ms
4,376 KB
testcase_37 AC 2 ms
4,376 KB
testcase_38 AC 104 ms
4,588 KB
testcase_39 AC 105 ms
4,480 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <array>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <fstream>
#include <complex>
#include <cstring>
#include <unordered_map>
#include <unordered_set>
#include <memory>
using namespace std;

// #pragma GCC optimize("O3")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
// #pragma GCC target("avx512f,avx512dq,avx512cd,avx512bw,avx512vl")

using ll = long long;
constexpr int INF = 1001001001;
// constexpr int mod = 1000000007;
constexpr int mod = 998244353;

template<class T>
inline bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int N, X, Y;
    cin >> N >> X >> Y;
    vector<int> A(N), B(N), C(N);
    for(int i = 0; i < N; ++i)  cin >> A[i] >> B[i] >> C[i];

    vector dp(X + 1, vector<ll>(Y + 1, -1));
    dp[0][0] = 0;
    for(int i = 0; i < N; ++i){
        auto dp2 = dp;
        for(int j = 0; j + A[i] <= X; ++j){
            for(int k = 0; k + B[i] <= Y; ++k){
                if(dp[j][k] == -1)  continue;
                chmax(dp2[j + A[i]][k + B[i]], dp[j][k] + C[i]);
            }
        }
        dp = move(dp2);
    }

    ll ans = 0;
    for(int i = 0; i <= X; ++i){
        for(int j = 0; j <= Y; ++j){
            chmax(ans, dp[i][j]);
        }
    }

    cout << ans << endl;

    return 0;
}
0