結果

問題 No.2730 Two Types Luggage
ユーザー zatsu308zatsu308
提出日時 2024-04-19 21:30:02
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,727 bytes
コンパイル時間 1,698 ms
コンパイル使用メモリ 171,460 KB
実行使用メモリ 18,948 KB
最終ジャッジ日時 2024-04-19 21:30:12
合計ジャッジ時間 5,550 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 8 ms
6,940 KB
testcase_11 AC 155 ms
14,932 KB
testcase_12 AC 263 ms
18,796 KB
testcase_13 AC 121 ms
12,648 KB
testcase_14 AC 151 ms
14,900 KB
testcase_15 AC 100 ms
6,944 KB
testcase_16 AC 54 ms
7,552 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

constexpr ll mod = 998244353;

template<ll mod>
struct Mint {
  using M=Mint; ll v;
  M& put(ll x) { v=(x<mod)?x:x-mod; return *this; }
  Mint(ll x=0) { put(x%mod+mod); }
  M operator+(M m) {return M().put(v+m.v);}
  M operator-(M m) {return M().put(v+mod-m.v);}
  M operator*(M m) {return M().put(v*m.v%mod);}
  M operator/(M m) {return M().put(v*m.inv().v%mod);}
// BEGIN IGNORE
  M operator+=(M m) { return put(v+m.v); }
  M operator-=(M m) { return put(v+mod-m.v); }
  M operator*=(M m) { return put(v*m.v%mod); }
  M operator/=(M m) { return put(v*m.inv().v%mod); }
// END IGNORE
  bool operator==(M m) { return v==m.v; }
  M pow(ll m) const {
    M x=v, res=1;
    while (m) {
      if (m&1) res=res*x;
      x=x*x; m>>=1;
    }
    return res;
  }
  M inv() { return pow(mod-2); }
};

using mint = Mint<mod>;

int main(){

  cin.tie(0);
  cin.sync_with_stdio(0);

  int n, m, w;
  cin >> n >> m >> w;
  vector<ll> a(n), b(m), c(m);
  for(int i = 0; i < n; ++i){
    cin >> a[i];
  }
  for(int j = 0; j < m; ++j){
    cin >> b[j];
  }
  for(int i = 0; i < m; ++i){
    cin >> c[i];
  }
  ll ans = 0;
  sort(a.begin(), a.end(), greater<>());
  vector<ll> r(n + 1);
  for(int i = 0; i < n; ++i){
    r[i + 1] = r[i] + a[i];
  }

  auto add = [&](ll rem){
    if(rem < r.size()){
      return r[rem];
    }
    else return r.back();
  };

  ll amax = *max_element(a.begin(), a.end());
  for(int i = 0; i < (1 << m); ++i){
    ll wei = 0, val = 0;
    for(int j = 0; j < m; ++j){
      if(i & (1 << j)){
        wei += b[j];
        val += c[j];
      }
    }
    if(wei <= w){
      ans = max(ans, add(w - wei) + val);
    }
  }
  cout << ans << endl;
}
0