結果
問題 | No.2329 Nafmo、イカサマをする |
ユーザー |
|
提出日時 | 2023-04-22 18:05:01 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 717 bytes |
コンパイル時間 | 2,122 ms |
コンパイル使用メモリ | 199,884 KB |
最終ジャッジ日時 | 2025-02-12 13:06:43 |
ジャッジサーバーID (参考情報) |
judge4 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 9 WA * 31 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int n; long long m; cin >> n >> m; vector<long long> a(n); for(int i = 0; i < n; i++){ cin >> a[i]; } vector<long long> b = a; for(int i = 0; i < n; i++){ for(int j = 0; j < n; j++){ b.emplace_back(a[i] + a[j]); } } sort(b.begin(), b.end()); long long ans = 0; for(auto x : b){ if(x > m) continue; ans = max(ans, x); auto iter = upper_bound(b.begin(), b.end(), m - x); if(iter == b.begin()) continue; iter--; ans = max(ans, x + *iter); } cout << ans << endl; }