結果

問題 No.2730 Two Types Luggage
ユーザー 👑 kmjpkmjp
提出日時 2024-04-19 22:45:00
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 281 ms / 2,000 ms
コード長 1,216 bytes
コンパイル時間 2,007 ms
コンパイル使用メモリ 198,068 KB
実行使用メモリ 15,360 KB
最終ジャッジ日時 2024-04-19 22:45:10
合計ジャッジ時間 8,675 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,248 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 6 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 8 ms
5,376 KB
testcase_11 AC 156 ms
12,288 KB
testcase_12 AC 271 ms
15,104 KB
testcase_13 AC 128 ms
10,496 KB
testcase_14 AC 152 ms
12,032 KB
testcase_15 AC 105 ms
5,632 KB
testcase_16 AC 60 ms
6,656 KB
testcase_17 AC 199 ms
14,592 KB
testcase_18 AC 181 ms
13,568 KB
testcase_19 AC 17 ms
5,376 KB
testcase_20 AC 73 ms
7,424 KB
testcase_21 AC 144 ms
11,648 KB
testcase_22 AC 204 ms
14,848 KB
testcase_23 AC 22 ms
5,376 KB
testcase_24 AC 87 ms
8,320 KB
testcase_25 AC 156 ms
12,416 KB
testcase_26 AC 43 ms
5,888 KB
testcase_27 AC 144 ms
11,648 KB
testcase_28 AC 79 ms
7,808 KB
testcase_29 AC 187 ms
13,824 KB
testcase_30 AC 84 ms
5,376 KB
testcase_31 AC 121 ms
10,240 KB
testcase_32 AC 106 ms
9,472 KB
testcase_33 AC 272 ms
15,232 KB
testcase_34 AC 272 ms
15,360 KB
testcase_35 AC 271 ms
15,360 KB
testcase_36 AC 281 ms
15,104 KB
testcase_37 AC 274 ms
15,232 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define FORR2(x,y,arr) for(auto& [x,y]:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
template<class T> bool chmax(T &a, const T &b) { if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a, const T &b) { if(a>b){a=b;return 1;}return 0;}
//-------------------------------------------------------


int N,M;
int A[1010101];
ll S[1010101];
ll W,B[20],C[20];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>M>>W;
	FOR(i,N) cin>>A[i];
	sort(A,A+N);
	reverse(A,A+N);
	FOR(i,N) S[i+1]=S[i]+A[i];
	
	ll ret=0;
	FOR(i,M) cin>>B[i];
	FOR(i,M) cin>>C[i];
	int mask;
	FOR(mask,1<<M) {
		ll w=0,v=0;
		FOR(i,M) if(mask&(1<<i)) w+=B[i], v+=C[i];
		if(w<=W) ret=max(ret,v+S[min(W-w,(ll)N)]);
	}
	cout<<ret<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}
0