結果

問題 No.2730 Two Types Luggage
ユーザー rotti_coderrotti_coder
提出日時 2024-04-19 21:36:47
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 580 ms / 2,000 ms
コード長 714 bytes
コンパイル時間 932 ms
コンパイル使用メモリ 85,320 KB
実行使用メモリ 11,136 KB
最終ジャッジ日時 2024-04-19 21:37:05
合計ジャッジ時間 12,810 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 2 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 369 ms
9,068 KB
testcase_12 AC 563 ms
10,908 KB
testcase_13 AC 295 ms
7,808 KB
testcase_14 AC 371 ms
9,188 KB
testcase_15 AC 165 ms
5,376 KB
testcase_16 AC 135 ms
5,504 KB
testcase_17 AC 474 ms
10,624 KB
testcase_18 AC 436 ms
9,984 KB
testcase_19 AC 39 ms
5,376 KB
testcase_20 AC 174 ms
5,888 KB
testcase_21 AC 351 ms
8,824 KB
testcase_22 AC 494 ms
10,752 KB
testcase_23 AC 50 ms
5,376 KB
testcase_24 AC 205 ms
6,400 KB
testcase_25 AC 378 ms
9,088 KB
testcase_26 AC 102 ms
5,376 KB
testcase_27 AC 350 ms
8,820 KB
testcase_28 AC 187 ms
6,144 KB
testcase_29 AC 443 ms
10,104 KB
testcase_30 AC 112 ms
5,376 KB
testcase_31 AC 285 ms
7,792 KB
testcase_32 AC 255 ms
7,424 KB
testcase_33 AC 572 ms
11,008 KB
testcase_34 AC 561 ms
11,008 KB
testcase_35 AC 577 ms
10,880 KB
testcase_36 AC 566 ms
11,136 KB
testcase_37 AC 580 ms
11,008 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
#include<bitset>
#include<algorithm>
using namespace std;
int main()
{
  long long n,m,w;
  cin >> n >> m >> w;
  vector<long long>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];
  sort(A.rbegin(),A.rend());
  for(int i=1;i<n;i++)A[i]+=A[i-1];
  long long ans=0;
  for(int tmp=0;tmp<(1<<m);tmp++){
    bitset<20>s(tmp);
    long long cnt=0;
    long long count=0;
    for(int i=0;i<m;i++)if(s[i]){
	cnt+=B[i];
	count+=C[i];
      }
    if(cnt>w)continue;
    if(cnt<w)count+=A[min(w-cnt-1,(long long)A.size()-1)];
    ans=max(ans,count);
  }
  cout << max(ans,A[min(w-1,(long long)A.size()-1)]) << endl;
}
0