結果
| 問題 |
No.2730 Two Types Luggage
|
| コンテスト | |
| ユーザー |
eve__fuyuki
|
| 提出日時 | 2024-04-19 21:26:44 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 291 ms / 2,000 ms |
| コード長 | 1,078 bytes |
| コンパイル時間 | 2,081 ms |
| コンパイル使用メモリ | 200,240 KB |
| 最終ジャッジ日時 | 2025-02-21 03:41:16 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 35 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
void fast_io() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
}
int main() {
fast_io();
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> cum(n + 1);
for (int i = 0; i < n; i++) {
cum[i + 1] = cum[i] + a[i];
}
long long ans = 0;
for (int st = 0; st < (1 << m); st++) {
long long sum = 0, weight = 0;
for (int i = 0; i < m; i++) {
if (st & (1 << i)) {
sum += c[i];
weight += b[i];
}
}
if (weight > w) {
continue;
}
if (weight + n <= w) {
ans = max(ans, sum + cum[n]);
} else {
ans = max(ans, sum + cum[w - weight]);
}
}
cout << ans << endl;
}
eve__fuyuki