結果
問題 | No.2317 Expression Menu |
ユーザー |
![]() |
提出日時 | 2023-10-26 04:43:35 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 80 ms / 2,000 ms |
コード長 | 1,187 bytes |
コンパイル時間 | 1,216 ms |
コンパイル使用メモリ | 124,224 KB |
最終ジャッジ日時 | 2025-02-17 13:47:48 |
ジャッジサーバーID (参考情報) |
judge2 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 37 |
ソースコード
#include<iostream>#include<vector>#include<algorithm>#include<cstring>#include<cassert>#include<cmath>#include<ctime>#include<iomanip>#include<numeric>#include<stack>#include<queue>#include<map>#include<unordered_map>#include<set>#include<unordered_set>#include<bitset>#include<random>#include<functional>#include<utility>using namespace std;int N,X,Y;long long dp[2][301][301];void solve(){cin >> N >> X >> Y;int cur = 0;for(int j = 0;j <= X;j++)for(int k = 0;k <= Y;k++) dp[cur][j][k] = -(long long)1e18;dp[cur][0][0] = 0;for(int i = 0;i < N;i++){int nxt = 1-cur;for(int j = 0;j <= X;j++)for(int k = 0;k <= Y;k++) dp[nxt][j][k] = -(long long)1e18;int A,B,C;cin >> A >> B >> C;for(int j = 0;j <= X;j++)for(int k = 0;k <= Y;k++){dp[nxt][j][k] = max(dp[nxt][j][k],dp[cur][j][k]);if(j+A <= X && k+B <= Y) dp[nxt][j+A][k+B] = max(dp[nxt][j+A][k+B],dp[cur][j][k]+C);}swap(cur,nxt);}long long ans = 0;for(int j = 0;j <= X;j++)for(int k = 0;k <= Y;k++) ans = max(ans,dp[cur][j][k]);cout << ans << endl;}int main(){ios::sync_with_stdio(false);cin.tie(nullptr);int tt = 1;//cin >> tt;while(tt--) solve();}