結果
問題 | No.2730 Two Types Luggage |
ユーザー |
![]() |
提出日時 | 2024-04-19 22:23:36 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 578 ms / 2,000 ms |
コード長 | 1,781 bytes |
コンパイル時間 | 5,390 ms |
コンパイル使用メモリ | 315,484 KB |
実行使用メモリ | 18,816 KB |
最終ジャッジ日時 | 2024-10-11 15:52:40 |
合計ジャッジ時間 | 16,966 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 35 |
ソースコード
#include <bits/stdc++.h>#include <atcoder/all>using namespace std;typedef long long ll;typedef long double ld;#define int ll#define OVERLOAD_REP(_1, _2, _3, name, ...) name#define REP2(i, l, r) for (int i = (int)(l); i < (int)(r); i++)#define REP1(i, n) REP2(i, 0, n)#define rep(...) OVERLOAD_REP(__VA_ARGS__, REP2, REP1)(__VA_ARGS__)#define RREP2(i, l, r) for (int i = (int)(l)-1; i >= (int)(r); i--)#define RREP1(i, n) RREP2(i, n, 0)#define rrep(...) OVERLOAD_REP(__VA_ARGS__, RREP2, RREP1)(__VA_ARGS__)#define all(...) begin(__VA_ARGS__), end(__VA_ARGS__)#define rall(...) rbegin(__VA_ARGS__), rend(__VA_ARGS__)#define debug(x) cerr << #x << ": " << (x) << endl#define pb push_back#define mp make_pair#define mt make_tupleconst int INF = 4e18;const int MOD = 1e9 + 7;const int MOD2 = 998244353;template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }template<class... T> void input(T&... args) { ((cin >> args), ...); }template<class... T> void print(T... args) { ((cout << args << " "), ...); }template<class... T> void println(T... args) { print(args...); cout << endl; }signed main() {int N, M, W;input(N, M, W);vector<int> A(N);rep(i, N) input(A[i]);vector<int> B(M);rep(i, M) input(B[i]);vector<int> C(M);rep(i, M) input(C[i]);sort(rall(A));vector<int> A_acc(N+1);rep(i, N) A_acc[i+1] = A_acc[i] + A[i];int ans = 0;rep(i, 1 << M) {int weight = 0;int value = 0;rep(j, M) {if (i >> j & 1) {weight += B[j];value += C[j];if (W < weight) break;}}if (W < weight) break;chmax(ans, value + A_acc[min(W - weight, N)]);}println(ans);}