結果

問題 No.2730 Two Types Luggage
ユーザー MMMM
提出日時 2024-04-19 21:33:54
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 521 ms / 2,000 ms
コード長 1,070 bytes
コンパイル時間 3,594 ms
コンパイル使用メモリ 228,444 KB
実行使用メモリ 18,944 KB
最終ジャッジ日時 2024-04-19 21:34:28
合計ジャッジ時間 14,352 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 5 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 15 ms
5,376 KB
testcase_11 AC 333 ms
14,848 KB
testcase_12 AC 512 ms
18,764 KB
testcase_13 AC 279 ms
12,544 KB
testcase_14 AC 344 ms
14,848 KB
testcase_15 AC 150 ms
6,272 KB
testcase_16 AC 121 ms
7,424 KB
testcase_17 AC 429 ms
18,176 KB
testcase_18 AC 406 ms
17,032 KB
testcase_19 AC 37 ms
5,376 KB
testcase_20 AC 161 ms
8,832 KB
testcase_21 AC 322 ms
14,172 KB
testcase_22 AC 452 ms
18,560 KB
testcase_23 AC 47 ms
5,376 KB
testcase_24 AC 193 ms
9,748 KB
testcase_25 AC 343 ms
15,104 KB
testcase_26 AC 93 ms
6,400 KB
testcase_27 AC 321 ms
14,208 KB
testcase_28 AC 175 ms
9,216 KB
testcase_29 AC 394 ms
16,896 KB
testcase_30 AC 106 ms
5,376 KB
testcase_31 AC 264 ms
12,288 KB
testcase_32 AC 233 ms
11,392 KB
testcase_33 AC 521 ms
18,944 KB
testcase_34 AC 515 ms
18,816 KB
testcase_35 AC 521 ms
18,944 KB
testcase_36 AC 511 ms
18,816 KB
testcase_37 AC 512 ms
18,816 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#include<atcoder/all>
#define chmin(x,y) (x) = min((x),(y))
#define chmax(x,y) (x) = max((x),(y))
#define ld long double
using namespace std;
using namespace atcoder;
using ll = long long;
const ll mod = 998244353;
using mint = modint998244353;
using Graph = vector<vector<pair<int,int>>>;
const vector<int> dx = {1,0,-1,0}, dy = {0,1,0,-1};

int main(){
  // input
  int N,M; ll 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 i = 0; i < M; i++) cin >> B[i];
  for(int i = 0; i < M; i++) cin >> C[i];
  // prep
  sort(A.begin(),A.end(),greater<ll>{});
  vector<ll> S(N+1);
  for(int i = 0; i < N; i++) S[i+1] = S[i] + A[i];
  
  // solve
  ll ans = 0;
  for(int bt = 0; bt < (1<<M); bt++){
    ll tmp = 0, wei = 0;
    for(int i = 0; i < M; i++){
      if(bt & (1<<i)){
        wei += B[i];
        tmp += C[i];
      }
    }
    
    if(wei > W) continue;
    
    ll can = min(max(0LL, W - wei),ll(N));
    tmp += S[can];
    chmax(ans,tmp);
  }
  
  // output
  cout << ans << endl;
}
0