結果
| 問題 |
No.2730 Two Types Luggage
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-04-19 21:31:52 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 285 ms / 2,000 ms |
| コード長 | 1,812 bytes |
| コンパイル時間 | 2,255 ms |
| コンパイル使用メモリ | 201,772 KB |
| 最終ジャッジ日時 | 2025-02-21 03:47:46 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 35 |
ソースコード
/*
#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("avx2,fma,bmi,bmi2,sse4.2,popcnt,lzcnt")
*/
#include <bits/stdc++.h>
#define taskname ""
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define i64 long long
#define pb push_back
#define ff first
#define ss second
#define isz(x) (int)x.size()
using namespace std;
const int mxN = 2e5 + 5;
const int mod = 1e9 + 7;
const i64 oo = 1e18;
void solve() {
int n, m; i64 w;
cin >> n >> m >> w;
vector<int> a(n), b(m), c(m);
for (auto &val : a) cin >> val;
for (auto &val : b) cin >> val;
for (auto &val : c) cin >> val;
sort(rall(a));
vector<i64> pfx(n + 1);
for (int i = 0; i < n; ++i) pfx[i + 1] = pfx[i] + a[i];
i64 res = 0;
for (int i = 0; i < (1 << m); ++i) {
i64 cw = w, sum = 0;
for (int j = 0; j < m; ++j) if (i >> j & 1) {
cw -= b[j];
sum += c[j];
}
if (cw < 0) continue;
cw = min<i64>(cw, n);
sum += pfx[cw];
res = max(res, sum);
}
cout << res << endl;
}
signed main() {
#ifndef CDuongg
if(fopen(taskname".inp", "r"))
assert(freopen(taskname".inp", "r", stdin)), assert(freopen(taskname".out", "w", stdout));
#else
freopen("bai3.inp", "r", stdin);
freopen("bai3.out", "w", stdout);
auto start = chrono::high_resolution_clock::now();
#endif
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int t = 1; //cin >> t;
while(t--) solve();
#ifdef CDuongg
auto end = chrono::high_resolution_clock::now();
cout << "\n"; for(int i = 1; i <= 100; ++i) cout << '=';
cout << "\nExecution time: " << chrono::duration_cast<chrono::milliseconds> (end - start).count() << "[ms]" << endl;
cout << "Check array size pls sir" << endl;
#endif
}