結果
| 問題 |
No.2317 Expression Menu
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-07-05 14:56:37 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 47 ms / 2,000 ms |
| コード長 | 1,122 bytes |
| コンパイル時間 | 950 ms |
| コンパイル使用メモリ | 102,088 KB |
| 最終ジャッジ日時 | 2025-02-15 06:15:11 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 37 |
ソースコード
/*
AC
制約からDP
*/
#include<iostream>
#include<set>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<map>
#include<numeric>
#include<queue>
#include<cmath>
using namespace std;
typedef long long ll;
const ll INF=1LL<<60;
typedef pair<ll,ll> P;
typedef pair<int,P> PP;
const ll MOD=998244353;
int main(){
int N,X,Y;
cin>>N>>X>>Y;
vector<ll> A(N),B(N),C(N);
for(int i=0;i<N;i++){
cin>>A[i]>>B[i]>>C[i];
}
vector<vector<ll>> dp(X+1,vector<ll>(Y+1,-INF));
//i番目の機能は1回しか用いないので 大きいほうから行うことで処理
dp[0][0]=0;
for(int i=0;i<N;i++){
for(int x=X;x>=0;x--){
for(int y=Y;y>=0;y--){
if(x-A[i]>=0 && y-B[i]>=0 && dp[x-A[i]][y-B[i]]!=-INF){
dp[x][y] = max(dp[x][y],dp[x-A[i]][y-B[i]]+C[i]);
}
}
}
}
ll ans=-INF;
for(int x=X;x>=0;x--){
for(int y=Y;y>=0;y--){
if(dp[x][y]!=-INF){
ans=max(ans,dp[x][y]);
}
}
}
cout<<ans<<endl;
}