結果
問題 | No.2730 Two Types Luggage |
ユーザー |
![]() |
提出日時 | 2024-04-22 00:20:47 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 1,886 ms / 2,000 ms |
コード長 | 888 bytes |
コンパイル時間 | 3,333 ms |
コンパイル使用メモリ | 262,220 KB |
実行使用メモリ | 84,480 KB |
最終ジャッジ日時 | 2024-10-13 22:53:10 |
合計ジャッジ時間 | 25,565 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 35 |
ソースコード
#include <bits/stdc++.h>using namespace std;#ifdef LOCAL#include "settings/debug.cpp"#define _GLIBCXX_DEBUG#else#define Debug(...) void(0)#endif#define rep(i, n) for (int i = 0; i < (n); ++i)using ll = long long;using ull = unsigned long long;int main() {ll n, m, w;cin >> n >> m >> w;vector<ll> a(n), b(m), c(m);rep(i, n) cin >> a[i];rep(i, m) cin >> b[i];rep(i, m) cin >> c[i];map<ll, ll> mp;rep(bit, 1 << m) {ll wei = 0, val = 0;rep(i, m) {if (bit & (1 << i)) {wei += b[i];val += c[i];}}mp[wei] = max(mp[wei], val);}sort(a.rbegin(), a.rend());vector<ll> sum(n + 1, 0);rep(i, n) sum[i + 1] = sum[i] + a[i];ll ans = sum[min(n, w)];for (auto [wei, val] : mp) {if (wei > w) continue;ans = max(ans, sum[min(n, w - wei)] + val);}cout << ans << endl;return 0;}