結果
問題 | No.2232 Miser's Gift |
ユーザー |
![]() |
提出日時 | 2023-03-03 23:13:08 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 42 ms / 2,000 ms |
コード長 | 562 bytes |
コンパイル時間 | 2,005 ms |
コンパイル使用メモリ | 195,648 KB |
最終ジャッジ日時 | 2025-02-11 04:24:00 |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 55 |
ソースコード
#define rep(i,n) for(int i=0;i<(int)(n);i++) #define ALL(v) v.begin(),v.end() typedef long long ll; #include<bits/stdc++.h> using namespace std; ll dp[110][100100]; int main(){ ios::sync_with_stdio(false); std::cin.tie(nullptr); int n,w; cin>>n>>w; vector<ll> W(n+1),V(n+1); rep(i,n) cin>>W[i+1]>>V[i+1]; for(int i=1;i<=n;i++){ for(int j=0;j<=w;j++){ dp[i][j]=dp[i-1][j]; if(j-W[i]>=0) dp[i][j]=max(dp[i][j],dp[i-1][j-W[i]]+V[i]); } } for(int i=1;i<=w;i++){ cout<<dp[n][w]+1-dp[n][w-i]<<'\n'; } return 0; }