結果

問題 No.1522 Unfairness
ユーザー 沙耶花沙耶花
提出日時 2021-05-28 21:37:20
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 684 bytes
コンパイル時間 4,140 ms
コンパイル使用メモリ 264,908 KB
実行使用メモリ 73,816 KB
最終ジャッジ日時 2023-08-07 05:40:52
合計ジャッジ時間 6,162 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,384 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 75 ms
73,504 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 2 ms
4,384 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 2 ms
4,380 KB
testcase_28 AC 2 ms
4,376 KB
testcase_29 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main(){
	
	int N,M;
	cin>>N>>M;
	
	vector<long long> A(N);
	rep(i,N)cin>>A[i];
	
	sort(A.rbegin(),A.rend());
	
	vector<vector<long long>> dp(N+1,vector<long long>(M+1,0));
	
	rep(i,N){
		rep(j,M+1){
			dp[i+1][j] = max(dp[i+1][j],dp[i][j]);
			if(i==N-1)continue;
			int X = A[i] - A[i+1];
			if(j+X>M)break;
			dp[i+2][j+X] = max(dp[i+2][j+X],dp[i][j] + A[i]);
		}
	}
	
	long long ans =0 ;
	rep(i,M+1)ans = max(ans,dp.back()[i]);
	
	cout<<ans<<endl;
	
	return 0;
}
0