結果

問題 No.2317 Expression Menu
ユーザー shobonvipshobonvip
提出日時 2023-05-26 21:30:02
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 165 ms / 2,000 ms
コード長 1,036 bytes
コンパイル時間 4,118 ms
コンパイル使用メモリ 266,036 KB
実行使用メモリ 4,824 KB
最終ジャッジ日時 2023-08-26 10:23:01
合計ジャッジ時間 10,252 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 11 ms
4,612 KB
testcase_03 AC 129 ms
4,564 KB
testcase_04 AC 131 ms
4,572 KB
testcase_05 AC 133 ms
4,472 KB
testcase_06 AC 129 ms
4,528 KB
testcase_07 AC 129 ms
4,656 KB
testcase_08 AC 129 ms
4,596 KB
testcase_09 AC 131 ms
4,708 KB
testcase_10 AC 132 ms
4,540 KB
testcase_11 AC 131 ms
4,708 KB
testcase_12 AC 130 ms
4,652 KB
testcase_13 AC 128 ms
4,532 KB
testcase_14 AC 132 ms
4,564 KB
testcase_15 AC 129 ms
4,576 KB
testcase_16 AC 129 ms
4,704 KB
testcase_17 AC 131 ms
4,556 KB
testcase_18 AC 130 ms
4,560 KB
testcase_19 AC 132 ms
4,708 KB
testcase_20 AC 131 ms
4,536 KB
testcase_21 AC 129 ms
4,580 KB
testcase_22 AC 129 ms
4,704 KB
testcase_23 AC 154 ms
4,636 KB
testcase_24 AC 155 ms
4,808 KB
testcase_25 AC 155 ms
4,628 KB
testcase_26 AC 159 ms
4,568 KB
testcase_27 AC 154 ms
4,824 KB
testcase_28 AC 157 ms
4,656 KB
testcase_29 AC 157 ms
4,532 KB
testcase_30 AC 156 ms
4,648 KB
testcase_31 AC 156 ms
4,620 KB
testcase_32 AC 156 ms
4,580 KB
testcase_33 AC 2 ms
4,376 KB
testcase_34 AC 2 ms
4,380 KB
testcase_35 AC 3 ms
4,380 KB
testcase_36 AC 1 ms
4,380 KB
testcase_37 AC 2 ms
4,380 KB
testcase_38 AC 164 ms
4,472 KB
testcase_39 AC 165 ms
4,692 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
using namespace atcoder;

typedef modint998244353 mint;
typedef long long ll;

struct UnionFind{
	int n;
	vector<int> par;

	explicit UnionFind(int v): n(v), par(v,-1) {}

	void merge(int a, int b){
		int x = find(a);
		int y = find(b);
		if (x == y) return;
		if (-par[x] < -par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return;
	}

	int find(int x){
		if (par[x] < 0) return x;
		return par[x] = find(par[x]);
	}
};

int main(){
	int n, x, y; cin >> n >> x >> y;
	const ll INF = 1e18;
	vector<vector<ll>> dp(x+1, vector<ll>(y+1, -INF));
	dp[0][0] = 0;
	for (int i=0; i<n; i++){
		int a, b; ll c; cin >> a >> b >> c;
		vector<vector<ll>> ndp = dp;
		for (int s=0; s<=x; s++){
			if (s+a > x) break;
			for (int t=0; t<=y; t++){
				if (t+b > y) break;
				ndp[s+a][t+b] = max(ndp[s+a][t+b], dp[s][t] + c);
			}
		}
		dp = ndp;
	}
	ll ans = 0;
	for (int i=0; i<=x; i++){
		for (int j=0; j<=y; j++){
			ans = max(ans, dp[i][j]);
		}
	}
	cout << ans << endl;
}
0