結果
問題 | No.2317 Expression Menu |
ユーザー |
|
提出日時 | 2023-05-26 21:36:00 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 182 ms / 2,000 ms |
コード長 | 948 bytes |
コンパイル時間 | 752 ms |
コンパイル使用メモリ | 79,900 KB |
最終ジャッジ日時 | 2025-02-13 06:01:51 |
ジャッジサーバーID (参考情報) |
judge4 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 37 |
ソースコード
#include<iostream> #include<vector> #include<algorithm> using namespace std; using ll=long long; #define rep(i,n) for(int i=0;i<n;i++) #define rrep(i,n) for(int i=(n)-1;i>=0;i--) #define all(v) v.begin(),v.end() #define rall(v) v.rbegin(),v.rend() template<class T> bool chmax(T &a, T b){if (a < b){a = b;return true;} else return false;} template<class T> bool chmin(T &a, T b){if (a > b){a = b;return true;} else return false;} int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int N,X,Y; cin>>N>>X>>Y; vector dp(X+1,vector<ll>(Y+1,-1LL<<60)); dp[0][0]=0; rep(i,N){ int a,b; ll c; cin>>a>>b>>c; vector dp2(X+1,vector<ll>(Y+1,-1LL<<60)); rep(j,X-a+1)rep(k,Y-b+1){ chmax(dp2[j+a][k+b],dp[j][k]+c); } rep(j,X+1)rep(k,Y+1)chmax(dp[j][k],dp2[j][k]); } ll ans=-1LL<<60; rep(i,X+1)rep(j,Y+1)chmax(ans,dp[i][j]); cout<<ans<<"\n"; }