結果
問題 | No.2730 Two Types Luggage |
ユーザー | 唐揚げが壊わ |
提出日時 | 2024-04-19 21:43:26 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 551 ms / 2,000 ms |
コード長 | 9,142 bytes |
コンパイル時間 | 2,453 ms |
コンパイル使用メモリ | 217,516 KB |
実行使用メモリ | 18,944 KB |
最終ジャッジ日時 | 2024-10-11 14:34:56 |
合計ジャッジ時間 | 13,870 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 2 ms
5,248 KB |
testcase_02 | AC | 2 ms
5,248 KB |
testcase_03 | AC | 2 ms
5,248 KB |
testcase_04 | AC | 5 ms
5,248 KB |
testcase_05 | AC | 2 ms
5,248 KB |
testcase_06 | AC | 2 ms
5,248 KB |
testcase_07 | AC | 2 ms
5,248 KB |
testcase_08 | AC | 2 ms
5,248 KB |
testcase_09 | AC | 3 ms
5,248 KB |
testcase_10 | AC | 16 ms
5,248 KB |
testcase_11 | AC | 362 ms
14,848 KB |
testcase_12 | AC | 550 ms
18,652 KB |
testcase_13 | AC | 288 ms
12,416 KB |
testcase_14 | AC | 361 ms
14,940 KB |
testcase_15 | AC | 157 ms
6,272 KB |
testcase_16 | AC | 132 ms
7,552 KB |
testcase_17 | AC | 461 ms
18,056 KB |
testcase_18 | AC | 425 ms
16,808 KB |
testcase_19 | AC | 39 ms
5,248 KB |
testcase_20 | AC | 169 ms
8,704 KB |
testcase_21 | AC | 339 ms
14,208 KB |
testcase_22 | AC | 478 ms
18,532 KB |
testcase_23 | AC | 48 ms
5,248 KB |
testcase_24 | AC | 200 ms
9,548 KB |
testcase_25 | AC | 367 ms
14,964 KB |
testcase_26 | AC | 101 ms
6,400 KB |
testcase_27 | AC | 340 ms
14,132 KB |
testcase_28 | AC | 184 ms
9,216 KB |
testcase_29 | AC | 428 ms
16,896 KB |
testcase_30 | AC | 108 ms
5,248 KB |
testcase_31 | AC | 284 ms
12,388 KB |
testcase_32 | AC | 254 ms
11,264 KB |
testcase_33 | AC | 551 ms
18,944 KB |
testcase_34 | AC | 550 ms
18,816 KB |
testcase_35 | AC | 551 ms
18,944 KB |
testcase_36 | AC | 549 ms
18,944 KB |
testcase_37 | AC | 551 ms
18,880 KB |
ソースコード
#include <bits/stdc++.h> // #include <atcoder/all> // Ctrl + end using namespace std; using str = string; using vs = vector<string>; using ll = long long; using ld = long double; using vll = vector<long long>; using vvll = vector<vector<long long>>; using vvvll = vector<vector<vector<long long>>>; using vvvvll = vector<vector<vector<vector<long long>>>>; using vb = vector<bool>; using vvb = vector<vector<bool>>; using pll = pair<ll, ll>; using vpll = vector<pair<ll, ll>>; #define REP1(i, n) for (long long i = 0; i < n; i++) #define REP2(i, n, m) for (long long i = n; i < m; i++) #define REP3(i, n, d, m) \ for (long long i = n; (n < m) ? (i < m) : (i > m); i += d) #define OVERLOAD_REP(a, b, c, d, e, ...) e #define REP(...) OVERLOAD_REP(__VA_ARGS__, REP3, REP2, REP1)(__VA_ARGS__) #define REPv(itr, v) for (auto itr = v.begin(); itr != v.end(); itr++) #define REPIN(itr, v) \ for (auto itr = v.begin(); itr != v.end(); itr++) { \ cin >> *itr; \ } #define been(vec) vec.begin(), vec.end() #define LIN \ = []() { \ long long LONGLONG_INPUT; \ cin >> LONGLONG_INPUT; \ return LONGLONG_INPUT; \ }() #define SIN \ = []() { \ string STRING_INPUT; \ cin >> STRING_INPUT; \ return STRING_INPUT; \ }() #define SPNL(i, SIZE) (i + 1 == SIZE ? '\n' : ' ') template <class T> constexpr T gcd(const T &x, const T &y) { return (x % y) ? gcd(y, x % y) : y; } template <class T, class... R> constexpr T gcd(const T &x, const R &...y) { return gcd(x, gcd(y...)); } template <class T> constexpr T lcm(const T &x, const T &y) { return x / gcd(x, y) * y; } template <class T, class... R> constexpr T lcm(const T &x, const R &...y) { return lcm(x, lcm(y...)); } template <class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; } template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; } // 3要素で比較するとfunc(a,b,comp)と勘違いされるから「{...}」使う template <class... T> constexpr auto min(const T &...a) { return min(initializer_list<common_type_t<T...>>{a...}); } template <class... T> constexpr auto max(const T &...a) { return max(initializer_list<common_type_t<T...>>{a...}); } // tuple処理 template <size_t N = 0, class T, class F> void iterate_tuple(T &t, const F &func) { if constexpr (N < tuple_size_v<T>) { auto &x = get<N>(t); func(x); iterate_tuple<N + 1>(t, func); } } // ストリーム演算子 入力 template <class T1, class T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; } template <class... T> istream &operator>>(istream &is, tuple<T...> &t) { auto func = [&is](auto &t) { is >> t; }; iterate_tuple(t, func); return is; } template <class T> istream &operator>>(istream &is, vector<T> &v) { for (size_t i = 0, n = v.size(); i < n; i++) { is >> v[i]; } return is; } // ストリーム演算子 出力 template <class T1, class T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << p.first << " " << p.second << " "; return os; } template <class... T> ostream &operator<<(ostream &os, const tuple<T...> &t) { auto func = [&os](auto t) { os << t << " "; }; iterate_tuple(t, func); return os; } template <class T> ostream &operator<<(ostream &os, const vector<T> &v) { for (size_t i = 0, n = v.size(); i < n; i++) { os << v[i] << " "; } return os; } template <class T> ostream &operator<<(ostream &os, const vector<vector<T>> &v) { for (size_t i = 0, n = v.size(); i < n; i++) { os << v[i] << endl; } return os; } template <class T1, class T2> ostream &operator<<(ostream &os, const map<T1, T2> &mp) { for (auto itr = mp.begin(); itr != mp.end(); itr++) { os << "[" << itr->first << "]" << itr->second << endl; } return os; } template <class T1, class T2> ostream &operator<<(ostream &os, const unordered_map<T1, T2> &mp) { for (auto itr = mp.begin(); itr != mp.end(); itr++) { os << "[" << itr->first << "]" << itr->second << endl; } return os; } template <class T> void input(T &a) { cin >> a; } template <class T, class... R> void input(T &a, R &...b) { input(a), input(b...); } template <class... T> constexpr void output(const T &...a) { (cout << ... << (cout << a, " ")); cout << endl; } template <class T1, class T2> pair<T1, T2> operator+(const pair<T1, T2> &a, const pair<T1, T2> &b) { pair<T1, T2> ret; ret = make_pair(a.first + b.first, a.second + b.second); return ret; } template <class T1, class T2, class T3> pair<T1, T2> operator+(const pair<T1, T2> &a, const T3 &b) { pair<T1, T2> ret; ret = make_pair(a.first + b, a.second + b); return ret; } template <class T1, class T2> pair<T1, T2> operator-(const pair<T1, T2> &a, const pair<T1, T2> &b) { pair<T1, T2> ret; ret = make_pair(a.first - b.first, a.second - b.second); return ret; } template <class T1, class T2, class T3> pair<T1, T2> operator-(const pair<T1, T2> &a, const T3 &b) { pair<T1, T2> ret; ret = make_pair(a.first - b, a.second - b); return ret; } template <class T> vector<T> operator+(const vector<T> &a, const vector<T> &b) { // aとbのサイズは一致する必要がある。 assert(a.size() == b.size()); vector<T> ret = a; for (size_t i = 0; i < ret.size(); i++) { ret[i] = a[i] + b[i]; } return ret; } template <class T1, class T2> vector<T1> operator+(const vector<T1> &a, const T2 &b) { vector<T1> ret = a; for (size_t i = 0; i < ret.size(); i++) { ret[i] = a[i] + b; } return ret; } // 二次元配列aを右回転する template <class T> constexpr vector<vector<T>> rotate_90deg(const vector<vector<T>> &a) { vector<vector<T>> b(a.front().size(), vector<T>(a.size())); for (size_t i = 0; i < a.front().size(); i++) { for (size_t j = 0; j < a.size(); j++) { b[i][j] = (a[a.size() - 1 - j][i]); } } return b; } // 二次元配列aをelementで指定した要素を含み切るようにクリッピング vector<string> clip_vec2(const vector<string> &a, const char element) { ll left = LLONG_MAX, right = -1, top = LLONG_MAX, bottom = -1; for (size_t i = 0; i < a.size(); i++) { for (size_t j = 0; j < a.front().size(); j++) { if (a[i][j] == element) { chmin(top, (ll)i); chmax(bottom, (ll)i); chmin(left, (ll)j); chmax(right, (ll)j); } } } vector<string> b(abs(bottom - top), string(abs(right - left), ' ')); for (size_t i = 0; i < b.size(); i++) { for (size_t j = 0; j < b.front().size(); j++) { b[i][j] = a[i + top][j + left]; } } return b; } template <class T> constexpr vector<vector<T>> clip_vec2(const vector<vector<T>> &a, const T element) { ll left = LLONG_MAX, right = -1, top = LLONG_MAX, bottom = -1; for (size_t i = 0; i < a.size(); i++) { for (size_t j = 0; j < a.front().size(); j++) { if (a[i][j] == element) { chmin(top, (ll)i); chmax(bottom, (ll)i); chmin(left, (ll)j); chmax(right, (ll)j); } } } vector<vector<T>> b(abs(bottom - top), vector<T>(abs(right - left))); for (size_t i = 0; i < b.size(); i++) { for (size_t j = 0; j < b.front().size(); j++) { b[i][j] = a[i + top][j + left]; } } return b; } // 二次元配列aをelementで指定した要素で囲い込む vector<string> envelope_vec2(const vector<string> &a, const char element) { vector<string> b = a; for (size_t i = 0; i < b.size(); i++) { b[i].insert(b[i].end(), {element, element}); std::rotate(b[i].rbegin(), b[i].rbegin() + 1, b[i].rend()); } b.push_back(string(b[0].size(), element)); b.push_back(b.back()); std::rotate(b.rbegin(), b.rbegin() + 1, b.rend()); return b; } template <class T> constexpr vector<vector<T>> envelope_vec2(const vector<vector<T>> &a, const T element) { vector<vector<T>> b = a; for (size_t i = 0; i < b.size(); i++) { b[i].insert(b[i].end(), {element, element}); std::rotate(b[i].rbegin(), b[i].rbegin() + 1, b[i].rend()); } b.push_back(vector<T>(b[0].size(), element)); b.push_back(b.back()); std::rotate(b.rbegin(), b.rbegin() + 1, b.rend()); return b; } const long long mod1000 = 1000000007; const long long mod998 = 998244353; const string yes = "Yes"; const string no = "No"; int main() { ll n, m, w; input(n, m, w); vll a(n), b(m), c(m); input(a, b, c); sort(been(a)); reverse(been(a)); vll A(n + 1, 0); REP(i, n) { A[i + 1] = A[i] + a[i]; } ll ans = 0; ll BIT, p_sum, w_sum; REP(i, (1 << m)) { BIT = i, p_sum = 0, w_sum = 0; REP(j, m) { if (BIT & 1) { w_sum += b[j]; p_sum += c[j]; } BIT >>= 1; } if (w_sum <= w) { p_sum += A[min(w - w_sum, n)]; } else { continue; } chmax(ans, p_sum); #if LOCAL_ENVIROMENT_FLAG output(p_sum); #endif } cout << ans << endl; }