結果
問題 | No.2232 Miser's Gift |
ユーザー |
|
提出日時 | 2023-03-03 21:45:23 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 189 ms / 2,000 ms |
コード長 | 1,353 bytes |
コンパイル時間 | 2,115 ms |
コンパイル使用メモリ | 198,072 KB |
最終ジャッジ日時 | 2025-02-11 02:13:07 |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 55 |
ソースコード
#include<bits/stdc++.h> using namespace std; using ll = long long; using vi = vector<int>; using vs = vector<string>; using vvi = vector<vi>; using vll = vector<ll>; using vvll = vector<vll>; using pii = pair<int, int>; using pll = pair<ll, ll>; #define rep(i,j,n) for(ll i=j;i<n;i++) #define rp(i,n) rep(i,0,n) #define all(v) v.begin(), v.end() #define pb push_back #define yes {cout<<"Yes"; return 0;} #define no {cout<<"No"; return 0;} #define yn(jg){if(jg) yes; no;} #define Noo {cout<<-1; return 0;} #define NL {cout<<endl;} ll mod0 = 998244353; ll lmax = 9e18; ll inf = 2e9;//2147483647 double pi = 3.14159265358979; //cout<<setprecision(15)<<fixed<< #define aout(a) {for(auto I:a) cout<<I<<" ";cout<<endl;} #define bout(a) {for(auto J:a) aout(J);cout<<endl;} int main() { int n, ww; cin >> n >> ww; vi w(n), v(n); rp(i, n) cin >> w[i] >> v[i]; vvi dp(n, vi(ww + 10, 0)); rp(i, n) { if (i > 0) { rep(j, 1, ww + 10) { if (j >= w[i]) dp[i][j] = max(dp[i][j - 1], dp[i - 1][j - w[i]] + v[i]); else dp[i][j] = dp[i][j - 1]; if (i > 0) dp[i][j] = max(dp[i][j], dp[i - 1][j]); } } else { rp(j, ww + 10)if (j >= w[0]) dp[0][j] = v[0]; } } rep(i, 1, ww + 1) { cout << dp[n-1][ww] - dp[n-1][ww - i]+1 << endl; } }