結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 6 ms
5,376 KB
testcase_05 AC 3 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 3 ms
5,376 KB
testcase_10 AC 16 ms
5,376 KB
testcase_11 AC 372 ms
14,848 KB
testcase_12 AC 568 ms
18,624 KB
testcase_13 AC 299 ms
12,532 KB
testcase_14 AC 373 ms
14,908 KB
testcase_15 AC 169 ms
6,272 KB
testcase_16 AC 137 ms
7,424 KB
testcase_17 AC 502 ms
18,048 KB
testcase_18 AC 438 ms
16,896 KB
testcase_19 AC 39 ms
5,376 KB
testcase_20 AC 177 ms
8,704 KB
testcase_21 AC 350 ms
14,208 KB
testcase_22 AC 493 ms
18,688 KB
testcase_23 AC 50 ms
5,376 KB
testcase_24 AC 206 ms
9,600 KB
testcase_25 AC 382 ms
14,976 KB
testcase_26 AC 103 ms
6,656 KB
testcase_27 AC 349 ms
14,124 KB
testcase_28 AC 191 ms
9,340 KB
testcase_29 AC 443 ms
16,896 KB
testcase_30 AC 116 ms
5,376 KB
testcase_31 AC 290 ms
12,416 KB
testcase_32 AC 259 ms
11,264 KB
testcase_33 AC 571 ms
18,816 KB
testcase_34 AC 572 ms
18,816 KB
testcase_35 AC 572 ms
18,936 KB
testcase_36 AC 586 ms
18,816 KB
testcase_37 AC 569 ms
19,056 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