結果

問題 No.2329 Nafmo、イカサマをする
ユーザー m_99m_99
提出日時 2023-05-28 14:18:48
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 106 ms / 2,000 ms
コード長 1,107 bytes
コンパイル時間 4,443 ms
コンパイル使用メモリ 265,860 KB
実行使用メモリ 12,160 KB
最終ジャッジ日時 2023-08-27 09:29:05
合計ジャッジ時間 6,727 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 4 ms
4,376 KB
testcase_19 AC 20 ms
5,308 KB
testcase_20 AC 6 ms
4,376 KB
testcase_21 AC 23 ms
5,296 KB
testcase_22 AC 3 ms
4,376 KB
testcase_23 AC 27 ms
8,192 KB
testcase_24 AC 10 ms
4,380 KB
testcase_25 AC 6 ms
4,380 KB
testcase_26 AC 8 ms
4,376 KB
testcase_27 AC 7 ms
4,376 KB
testcase_28 AC 4 ms
4,376 KB
testcase_29 AC 7 ms
4,376 KB
testcase_30 AC 3 ms
4,380 KB
testcase_31 AC 31 ms
8,764 KB
testcase_32 AC 1 ms
4,376 KB
testcase_33 AC 7 ms
4,376 KB
testcase_34 AC 10 ms
4,376 KB
testcase_35 AC 3 ms
4,376 KB
testcase_36 AC 47 ms
8,388 KB
testcase_37 AC 17 ms
5,132 KB
testcase_38 AC 95 ms
11,916 KB
testcase_39 AC 98 ms
12,160 KB
testcase_40 AC 98 ms
11,816 KB
testcase_41 AC 106 ms
11,948 KB
testcase_42 AC 99 ms
11,600 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
using mint = modint998244353;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf32 1000000001
#define Inf64 4000000000000000001


int main(){
	
	long long N,M,K;
	cin>>N>>M>>K;
	
	vector<long long> a(N);
	rep(i,N)cin>>a[i];
	vector<long long> t;
	vector<vector<long long>> vs(4);
	rep(i,4)vs[i].push_back(0);
	rep(i,4){
		if(i==0)continue;
		rep(j,N)vs[i].push_back(a[j]);
	}
	rep(i,N){
		rep(j,N){
			rep(k,4){
				if(k>=2){
					vs[k].push_back(a[i]+a[j]);
					
				}
			}
		}
	}
	rep(i,N){
		rep(j,N){
			rep(k,N){
				rep(l,4){
					if(l==3){
						vs[l].push_back(a[i]+a[j]+a[k]);
					}
				}
			}
		}
	}
	rep(i,4){
		sort(vs[i].begin(),vs[i].end());
	}
	long long ans = 0;
	rep(i,4){
		int x = i;
		int y = K-i;
		if(y<0||y>=4)continue;
		rep(j,vs[x].size()){
			long long tt = vs[x][j];
			if(tt>M)continue;
			int d = distance(vs[y].begin(),upper_bound(vs[y].begin(),vs[y].end(),M-tt));
			d--;
			tt += vs[y][d];
			ans = max(ans,tt);
		}
	}
	cout<<ans<<endl;
	
	return 0;
}
0