結果
問題 |
No.2329 Nafmo、イカサマをする
|
ユーザー |
|
提出日時 | 2023-07-07 08:25:24 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,076 bytes |
コンパイル時間 | 2,245 ms |
コンパイル使用メモリ | 205,740 KB |
最終ジャッジ日時 | 2025-02-15 06:33:31 |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 37 WA * 3 |
ソースコード
typedef long long ll; typedef long double ld; #include <bits/stdc++.h> using namespace std; #define int long long signed main(){ ll n,m,k; std::cin >> n>>m>>k; vector<ll> a(n); vector<ll> b,c; for (int i = 0; i < n; i++) { std::cin >> a[i]; if(i<n/2){ b.push_back(a[i]); }else{ c.push_back(a[i]); } // // d.push_back(a[i]); // } } vector<set<ll>> v1(7); vector<set<ll>> v2(7); // vector<set<ll>> v3(k+1); v1[0].insert(0); v2[0].insert(0); // v3[0].insert(0); for (auto e : b) { for (int i = 0; i < 3; i++) { for (auto ee : v1[i]) { v1[i+1].insert(ee+e); } } } for (auto e : c) { for (int i = 0; i < 3; i++) { for (auto ee : v2[i]) { v2[i+1].insert(ee+e); } } } ll ans = 0; for (int i = 0; i <= 3; i++) { for (int j = 0; j <= 3; j++) { if(i+j>k)continue; for (auto e1 : v1[i]) { if(e1>m)break; auto it = v2[j].upper_bound(m-e1); if(it==v2[j].begin())continue; it--; ans = max(ans, e1+*it); } for (auto e1 : v2[i]) { if(e1>m)break; auto it = v1[j].upper_bound(m-e1); if(it==v1[j].begin())continue; it--; ans = max(ans, e1+*it); } for (auto e1 : v1[i]) { if(e1>m)break; auto it = v1[j].upper_bound(m-e1); if(it==v1[j].begin())continue; it--; ans = max(ans, e1+*it); } for (auto e1 : v2[i]) { if(e1>m)break; auto it = v2[j].upper_bound(m-e1); if(it==v2[j].begin())continue; it--; ans = max(ans, e1+*it); } } } std::cout << ans << std::endl; }