結果
| 問題 |
No.2730 Two Types Luggage
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-04-19 22:45:33 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 283 ms / 2,000 ms |
| コード長 | 818 bytes |
| コンパイル時間 | 1,987 ms |
| コンパイル使用メモリ | 202,396 KB |
| 最終ジャッジ日時 | 2025-02-21 04:59:42 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 35 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:13:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
13 | scanf("%d%d%lld", &n, &m, &k);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
main.cpp:17:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
17 | scanf("%lld", &v);
| ~~~~~^~~~~~~~~~~~
main.cpp:25:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
25 | scanf("%d", &y);
| ~~~~~^~~~~~~~~~
main.cpp:27:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
27 | scanf("%d", &x);
| ~~~~~^~~~~~~~~~
ソースコード
#include <bits/stdc++.h>
typedef long long LL;
typedef __int128 LLL;
const int N = 10;
const int MOD = 998244353;
int main() {
int n, m;
LL k;
scanf("%d%d%lld", &n, &m, &k);
std::vector<LL> a(n);
for(LL &v: a)
scanf("%lld", &v);
std::sort(a.begin(), a.end(), std::greater<LL>());
a.insert(a.begin(), 0);
for(int i = 1; i < a.size(); ++i)
a[i] += a[i - 1];
std::vector<std::pair<int, int>> b(m);
for(auto &[x, y]: b)
scanf("%d", &y);
for(auto &[x, y]: b)
scanf("%d", &x);
LL ans = 0;
for(int i = 0; i < (1 << m); ++i) {
LL v = 0, w = 0;
for(int j = 0; j < m; ++j)
if(i >> j & 1)
v += b[j].first, w += b[j].second;
if(w <= k)
ans = std::max(ans, v + (k - w < a.size() ? a[k - w] : a.back()));
}
printf("%lld\n", ans);
return 0;
}