結果
問題 | No.2329 Nafmo、イカサマをする |
ユーザー |
![]() |
提出日時 | 2023-05-28 15:32:27 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 895 bytes |
コンパイル時間 | 2,023 ms |
コンパイル使用メモリ | 199,420 KB |
最終ジャッジ日時 | 2025-02-13 13:31:46 |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 WA * 1 |
other | AC * 8 WA * 32 |
ソースコード
#include <bits/stdc++.h>using namespace std;using ll=long long;using pll=pair<ll,ll>;using tll=tuple<ll,ll,ll>;const ll INF=(1ll<<60);#define rep(i,n) for (ll i=0;i<(ll)(n);i++)#define all(v) v.begin(),v.end()template<class T> void chmin(T &a,T b){if(a>b){a=b;}}template<class T> void chmax(T &a,T b){if(a<b){a=b;}}int main(){ios::sync_with_stdio(false);cin.tie(nullptr);ll n,m,k;cin >> n >> m >> k;vector<ll> a(n);rep(i,n) cin >> a[i];vector<ll> v;rep(i,n){rep(j,n){rep(k,n){v.push_back(a[i]+a[j]+a[k]);}}}ll ans=0;sort(all(v));for(auto &i:v){if(m<i) continue;auto itr=upper_bound(all(v),m-i);if(itr!=v.begin()) itr--;if(i+(*itr)<=m) chmax(ans,i+(*itr));}cout << ans << '\n';}