結果

問題 No.2329 Nafmo、イカサマをする
ユーザー keisuke6keisuke6
提出日時 2023-05-28 14:09:07
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 114 ms / 2,000 ms
コード長 710 bytes
コンパイル時間 2,273 ms
コンパイル使用メモリ 207,372 KB
実行使用メモリ 13,372 KB
最終ジャッジ日時 2023-08-27 09:07:25
合計ジャッジ時間 4,557 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 3 ms
4,384 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 4 ms
4,380 KB
testcase_19 AC 19 ms
5,184 KB
testcase_20 AC 7 ms
4,380 KB
testcase_21 AC 23 ms
5,048 KB
testcase_22 AC 4 ms
4,376 KB
testcase_23 AC 24 ms
5,428 KB
testcase_24 AC 10 ms
4,380 KB
testcase_25 AC 5 ms
4,380 KB
testcase_26 AC 8 ms
4,380 KB
testcase_27 AC 7 ms
4,376 KB
testcase_28 AC 4 ms
4,376 KB
testcase_29 AC 6 ms
4,380 KB
testcase_30 AC 3 ms
4,380 KB
testcase_31 AC 30 ms
8,612 KB
testcase_32 AC 2 ms
4,376 KB
testcase_33 AC 6 ms
4,376 KB
testcase_34 AC 10 ms
4,376 KB
testcase_35 AC 3 ms
4,376 KB
testcase_36 AC 53 ms
7,556 KB
testcase_37 AC 16 ms
5,096 KB
testcase_38 AC 93 ms
11,720 KB
testcase_39 AC 95 ms
12,104 KB
testcase_40 AC 94 ms
13,372 KB
testcase_41 AC 114 ms
12,068 KB
testcase_42 AC 94 ms
11,524 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int N,M,K;
  cin>>N>>M>>K;
  vector<int> A(N,0);
  for(int i=0;i<N;i++) cin>>A[i];
  vector<int> T = {};
  vector<vector<int>> S(4);
  S[0].push_back(0);
  for(int x:A) S[1].push_back(x);
  for(int x:A)for(int y:A) S[2].push_back(x+y);
  for(int x:A)for(int y:A)for(int z:A) S[3].push_back(x+y+z);
  for(int i=0;i<4;i++) sort(S[i].begin(),S[i].end());
  int ans = 0;
  for(int i=0;i<4;i++)for(int j=i;j<4;j++){
  	if(i+j > K) continue;
  	for(int x:S[i]){
  		auto iter = upper_bound(S[j].begin(),S[j].end(),M-x);
  		if(iter == S[j].begin()) continue;
  		iter--;
  		ans = max(ans,x+(*iter));
  	}
  }
  cout<<ans<<endl;
}
0