結果

問題 No.2329 Nafmo、イカサマをする
ユーザー rurunrurun
提出日時 2023-05-28 14:55:39
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 729 bytes
コンパイル時間 2,115 ms
コンパイル使用メモリ 204,796 KB
実行使用メモリ 11,084 KB
最終ジャッジ日時 2023-08-27 10:53:58
合計ジャッジ時間 4,448 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,384 KB
testcase_03 WA -
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 2 ms
4,376 KB
testcase_17 WA -
testcase_18 AC 4 ms
4,380 KB
testcase_19 WA -
testcase_20 AC 7 ms
4,376 KB
testcase_21 AC 26 ms
4,860 KB
testcase_22 AC 3 ms
4,380 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 6 ms
4,380 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 AC 2 ms
4,376 KB
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 AC 53 ms
6,904 KB
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 AC 114 ms
11,084 KB
testcase_42 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using lint = long long;
int main() {
  lint n, m, k;
  cin >> n >> m >> k;
  vector<lint> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  a.push_back(0);
  n++;
  vector<lint> vec(n*n*n);
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      for (int k = 0; k < n; k++) {
        vec[cnt] = a[i]+a[j]+a[k];
        cnt++;
      }
    }
  }
  sort(vec.begin(), vec.end());
  lint ans = -1;
  for (int i = 0; i < n*n*n; i++) {
    auto itr = upper_bound(vec.begin(), vec.end(), m-vec[i]);
    if (itr == vec.begin()) continue;
    else {
    	int idx = itr-vec.begin()-1;
        ans = max(ans, vec[i]+vec[idx]);
    }
  }
  cout << ans << endl;

}
0