結果

問題 No.2730 Two Types Luggage
ユーザー 沙耶花沙耶花
提出日時 2024-04-19 21:25:30
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 571 ms / 2,000 ms
コード長 766 bytes
コンパイル時間 4,831 ms
コンパイル使用メモリ 258,244 KB
実行使用メモリ 18,816 KB
最終ジャッジ日時 2024-04-19 21:26:26
合計ジャッジ時間 17,244 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 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 3 ms
5,376 KB
testcase_10 AC 18 ms
5,376 KB
testcase_11 AC 388 ms
14,848 KB
testcase_12 AC 571 ms
18,560 KB
testcase_13 AC 308 ms
12,416 KB
testcase_14 AC 392 ms
14,976 KB
testcase_15 AC 165 ms
6,400 KB
testcase_16 AC 142 ms
7,552 KB
testcase_17 AC 491 ms
18,048 KB
testcase_18 AC 447 ms
16,768 KB
testcase_19 AC 41 ms
5,376 KB
testcase_20 AC 172 ms
8,704 KB
testcase_21 AC 353 ms
14,208 KB
testcase_22 AC 504 ms
18,560 KB
testcase_23 AC 48 ms
5,376 KB
testcase_24 AC 208 ms
9,728 KB
testcase_25 AC 392 ms
14,976 KB
testcase_26 AC 106 ms
6,400 KB
testcase_27 AC 368 ms
14,336 KB
testcase_28 AC 189 ms
9,216 KB
testcase_29 AC 437 ms
16,768 KB
testcase_30 AC 111 ms
5,376 KB
testcase_31 AC 290 ms
12,288 KB
testcase_32 AC 252 ms
11,136 KB
testcase_33 AC 553 ms
18,816 KB
testcase_34 AC 550 ms
18,816 KB
testcase_35 AC 545 ms
18,816 KB
testcase_36 AC 544 ms
18,816 KB
testcase_37 AC 548 ms
18,816 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using mint = modint998244353;
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf32 1000000001
#define Inf64 1000000000000000001

int main(){
	
	long long N,M,W;
	cin>>N>>M>>W;
	vector<long long> a(N);
	rep(i,N)cin>>a[i];
	sort(a.rbegin(),a.rend());
	a.insert(a.begin(),0);
	rep(i,N)a[i+1] += a[i];
	vector<long long> c(M),b(M);
	rep(i,M){
		cin>>b[i];
	}
	rep(i,M)cin>>c[i];
	long long ans = 0;
	rep(i,1<<M){
		long long rem = W;
		long long vs = 0;
		rep(j,M){
			
			if((i>>j)&1){
				rem -= b[j];
				vs += c[j];
			}
		}
		
		if(rem<0)continue;
		rem = min(rem,N);
		vs += a[rem];
		ans = max(ans,vs);
		
	}
	cout<<ans<<endl;
	
	return 0;
}
0