結果
問題 | No.2730 Two Types Luggage |
ユーザー |
![]() |
提出日時 | 2024-04-19 21:43:27 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 615 ms / 2,000 ms |
コード長 | 964 bytes |
コンパイル時間 | 2,921 ms |
コンパイル使用メモリ | 203,260 KB |
最終ジャッジ日時 | 2025-02-21 04:00:52 |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 35 |
ソースコード
#include <bits/stdc++.h>using namespace std;int main() {int n, m;long long w;cin >> n >> m >> w;vector<long long> a(n), b(m), c(m);for (int i = 0; i < n; i++) {cin >> a[i];}for (int i = 0; i < m; i++) {cin >> b[i];}for (int i = 0; i < m; i++) {cin >> c[i];}sort(a.rbegin(), a.rend());vector<long long> sum = {0LL};long long cur = 0LL;for (int i = 0; i < n; i++) {cur += a[i];sum.push_back(cur);}long long ans = 0LL;for (int bit = 0; bit < (1 << m); bit++) {long long wgt = 0LL, val = 0LL;for (int i = 0; i < m; i++) {if (bit & (1 << i)) {wgt += b[i];val += c[i];}}if (wgt > w) {continue;}long long res = min(w - wgt, (long long)n);ans = max(ans, val + sum[res]);}cout << ans << endl;}