結果
問題 | No.2730 Two Types Luggage |
ユーザー | IchigoYP |
提出日時 | 2024-04-19 23:37:13 |
言語 | C++23 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,655 bytes |
コンパイル時間 | 3,369 ms |
コンパイル使用メモリ | 259,180 KB |
実行使用メモリ | 371,380 KB |
最終ジャッジ日時 | 2024-10-11 18:20:49 |
合計ジャッジ時間 | 17,709 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 3 ms
5,248 KB |
testcase_02 | AC | 3 ms
5,248 KB |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | WA | - |
testcase_32 | WA | - |
testcase_33 | WA | - |
testcase_34 | WA | - |
testcase_35 | WA | - |
testcase_36 | WA | - |
testcase_37 | WA | - |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using ull = unsigned long long; using vll = vector<ll>; using vvll = vector<vector<ll>>; using P = pair<ll, ll>; using vp = vector<pair<ll, ll>>; #define mod 998244353 #define all(v) v.begin(), v.end() #define resort(v) sort(v.rbegin(), v.rend()) #define rep(i, n) for (ll i = 0; i < n; ++i) #define per(i, n) for (ll i = n - 1; i >= 0; --i) #define rep2(i, a, n) for (ll i = a; i < n; ++i) #define per2(i, a, n) for (ll i = n - 1; i >= a; --i) #define chmin(a, b) a = min(a, b) #define chmax(a, b) a = max(a, b) const ll inf = 1ll << 60; ll dx[] = {1,0,0,-1,1,-1,1,-1}; ll dy[] = {0,1,-1,0,1,1,-1,-1}; int main() { ll n, m, w, ans = 0; cin >> n >> m >> w; vll a(n), b(m), c(m), s(n + 1); rep(i, n) cin >> a[i]; rep(i, m) cin >> b[i]; rep(i, m) cin >> c[i]; resort(a); s[0] = 0; rep(i, n) s[i + 1] = s[i] + a[i]; vvll dp(m + 1, vll(1ll << m)); vvll dpw(m + 1, vll(1ll << m)); rep(i, m){ rep(j, (1ll << m)){ chmax(dp[i + 1][j], dp[i][j]); if(dpw[i][j] + b[i] <= w) chmax(dp[i + 1][j | (1ll << i)], dp[i][j] + c[i]); dpw[i + 1][j] = dpw[i][j]; dpw[i + 1][j | (1ll << i)] = dpw[i][j] + b[i]; } } ans = s[n]; rep(i, (1ll << m)){ //cout << dpw[m][i] << endl; //cout << "i: " << i << endl; // デバッグ情報: i の値を出力 if(dpw[m][i] > w) continue; if(w - dpw[m][i] >= 0 && w - dpw[m][i] < n) chmax(ans, dp[m][i] + s[w - dpw[m][i]]); else chmax(ans, dp[m][i]); } cout << ans << endl; }