結果
問題 | No.2232 Miser's Gift |
ユーザー | wanui |
提出日時 | 2023-03-03 21:46:34 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 257 ms / 2,000 ms |
コード長 | 1,887 bytes |
コンパイル時間 | 2,807 ms |
コンパイル使用メモリ | 205,348 KB |
実行使用メモリ | 98,144 KB |
最終ジャッジ日時 | 2023-10-18 01:43:21 |
合計ジャッジ時間 | 11,445 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,680 KB |
testcase_01 | AC | 2 ms
5,680 KB |
testcase_02 | AC | 2 ms
5,684 KB |
testcase_03 | AC | 257 ms
97,808 KB |
testcase_04 | AC | 176 ms
98,144 KB |
testcase_05 | AC | 34 ms
83,528 KB |
testcase_06 | AC | 2 ms
4,348 KB |
testcase_07 | AC | 16 ms
12,684 KB |
testcase_08 | AC | 203 ms
98,144 KB |
testcase_09 | AC | 204 ms
98,144 KB |
testcase_10 | AC | 205 ms
98,144 KB |
testcase_11 | AC | 202 ms
98,144 KB |
testcase_12 | AC | 202 ms
98,144 KB |
testcase_13 | AC | 199 ms
98,144 KB |
testcase_14 | AC | 205 ms
98,144 KB |
testcase_15 | AC | 202 ms
98,144 KB |
testcase_16 | AC | 203 ms
98,144 KB |
testcase_17 | AC | 202 ms
98,144 KB |
testcase_18 | AC | 202 ms
98,144 KB |
testcase_19 | AC | 205 ms
98,144 KB |
testcase_20 | AC | 202 ms
98,144 KB |
testcase_21 | AC | 201 ms
98,144 KB |
testcase_22 | AC | 200 ms
98,144 KB |
testcase_23 | AC | 204 ms
98,144 KB |
testcase_24 | AC | 192 ms
98,144 KB |
testcase_25 | AC | 193 ms
98,144 KB |
testcase_26 | AC | 193 ms
98,144 KB |
testcase_27 | AC | 198 ms
98,144 KB |
testcase_28 | AC | 186 ms
98,144 KB |
testcase_29 | AC | 186 ms
98,144 KB |
testcase_30 | AC | 186 ms
98,144 KB |
testcase_31 | AC | 190 ms
98,144 KB |
testcase_32 | AC | 188 ms
98,144 KB |
testcase_33 | AC | 195 ms
98,144 KB |
testcase_34 | AC | 196 ms
98,144 KB |
testcase_35 | AC | 195 ms
98,144 KB |
testcase_36 | AC | 200 ms
98,144 KB |
testcase_37 | AC | 195 ms
98,144 KB |
testcase_38 | AC | 19 ms
82,024 KB |
testcase_39 | AC | 19 ms
82,024 KB |
testcase_40 | AC | 20 ms
82,024 KB |
testcase_41 | AC | 19 ms
82,024 KB |
testcase_42 | AC | 19 ms
82,024 KB |
testcase_43 | AC | 20 ms
82,024 KB |
testcase_44 | AC | 19 ms
82,024 KB |
testcase_45 | AC | 19 ms
82,024 KB |
testcase_46 | AC | 19 ms
82,024 KB |
testcase_47 | AC | 19 ms
82,024 KB |
testcase_48 | AC | 18 ms
81,868 KB |
testcase_49 | AC | 18 ms
81,868 KB |
testcase_50 | AC | 18 ms
81,868 KB |
testcase_51 | AC | 18 ms
81,868 KB |
testcase_52 | AC | 18 ms
81,868 KB |
testcase_53 | AC | 18 ms
81,868 KB |
testcase_54 | AC | 18 ms
81,868 KB |
testcase_55 | AC | 18 ms
81,868 KB |
testcase_56 | AC | 18 ms
81,868 KB |
testcase_57 | AC | 18 ms
81,868 KB |
ソースコード
#include <bits/stdc++.h> // clang-format off using namespace std; using ll=long long; using ull=unsigned long long; using pll=pair<ll,ll>; const ll INF=4e18; void print0(){}; template<typename H,typename... T> void print0(H h,T... t){cout<<h;print0(t...);} void print(){print0("\n");}; template<typename H,typename... T>void print(H h,T... t){print0(h);if(sizeof...(T)>0)print0(" ");print(t...);} void perr0(){}; template<typename H,typename... T> void perr0(H h,T... t){cerr<<h;perr0(t...);} void perr(){perr0("\n");}; template<typename H,typename... T>void perr(H h,T... t){perr0(h);if(sizeof...(T)>0)perr0(" ");perr(t...);} void ioinit() { cout<<fixed<<setprecision(15); cerr<<fixed<<setprecision(6); ios_base::sync_with_stdio(0); cin.tie(0); } #define debug1(a) { cerr<<#a<<":"<<a<<endl; } #define debug2(a,b) { cerr<<#a<<":"<<a<<" "<<#b<<":"<<b<<endl; } #define debug3(a,b,c) { cerr<<#a<<":"<<a<<" "<<#b<<":"<<b<<" "<<#c<<":"<<c<<endl; } #define debug4(a,b,c,d) { cerr<<#a<<":"<<a<<" "<<#b<<":"<<b<<" "<<#c<<":"<<c<<" "<<#d<<":"<<d<<endl; } // clang-format on vector<pll> goods; ll W; ll dp(ll i, ll w) { static bool done[102][100005]; static ll memo[102][100005]; if (i < 0) return 0; if (done[i][w]) return memo[i][w]; done[i][w] = true; ll N = goods.size(); ll wi = goods[i].first; ll vi = goods[i].second; ll ans = dp(i - 1, w); if (w - wi >= 0) { ans = max(ans, vi + dp(i - 1, w - wi)); } if (w > 0) { ans = max(ans, dp(i, w - 1)); } return memo[i][w] = ans; } int main() { ioinit(); ll N; cin >> N >> W; for (ll i = 0; i < N; i++) { ll w, v; cin >> w >> v; goods.push_back({w, v}); } ll initans = dp(N - 1, W); for (ll x = 1; x <= W; x++) { ll cur = dp(N - 1, W - x); ll v = initans - cur + 1; print(v); } return 0; }