結果
| 問題 |
No.2730 Two Types Luggage
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-04-19 21:26:11 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 288 ms / 2,000 ms |
| コード長 | 718 bytes |
| コンパイル時間 | 2,092 ms |
| コンパイル使用メモリ | 201,860 KB |
| 最終ジャッジ日時 | 2025-02-21 03:39:22 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 35 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
long long N,M,W; cin >> N >> M >> W;
int m2 = 1<<M;
vector<long long> A(N),B(M),C(M);
for(auto &a : A) cin >> a;
for(auto &a : B) cin >> a;
for(auto &a : C) cin >> a;
sort(A.rbegin(),A.rend());
for(int i=1; i<N; i++) A.at(i) += A.at(i-1);
long long answer = 0;
for(int t=0; t<m2; t++){
long long v = 0,w = 0;
for(int i=0; i<M; i++) if(t&(1<<i)) w += B.at(i),v += C.at(i);
if(w > W) continue;
long long left = min(N,W-w);
if(left) v += A.at(left-1);
answer = max(answer,v);
}
cout << answer << endl;
}