結果
| 問題 |
No.2317 Expression Menu
|
| コンテスト | |
| ユーザー |
shobonvip
|
| 提出日時 | 2023-05-26 21:30:02 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 162 ms / 2,000 ms |
| コード長 | 1,036 bytes |
| コンパイル時間 | 3,684 ms |
| コンパイル使用メモリ | 255,864 KB |
| 最終ジャッジ日時 | 2025-02-13 05:52:37 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 37 |
ソースコード
#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;
}
shobonvip