結果

問題 No.1522 Unfairness
ユーザー 沙耶花沙耶花
提出日時 2021-05-28 21:40:04
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 83 ms / 2,000 ms
コード長 687 bytes
コンパイル時間 4,449 ms
コンパイル使用メモリ 267,912 KB
実行使用メモリ 73,856 KB
最終ジャッジ日時 2024-04-29 21:55:15
合計ジャッジ時間 6,150 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,248 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 23 ms
21,760 KB
testcase_04 AC 7 ms
8,064 KB
testcase_05 AC 4 ms
5,376 KB
testcase_06 AC 3 ms
5,376 KB
testcase_07 AC 33 ms
30,464 KB
testcase_08 AC 33 ms
30,208 KB
testcase_09 AC 3 ms
5,376 KB
testcase_10 AC 11 ms
11,008 KB
testcase_11 AC 6 ms
6,784 KB
testcase_12 AC 16 ms
15,488 KB
testcase_13 AC 46 ms
41,728 KB
testcase_14 AC 6 ms
6,784 KB
testcase_15 AC 81 ms
73,728 KB
testcase_16 AC 81 ms
73,856 KB
testcase_17 AC 83 ms
73,728 KB
testcase_18 AC 82 ms
73,856 KB
testcase_19 AC 83 ms
73,856 KB
testcase_20 AC 83 ms
73,728 KB
testcase_21 AC 2 ms
5,376 KB
testcase_22 AC 2 ms
5,376 KB
testcase_23 AC 2 ms
5,376 KB
testcase_24 AC 2 ms
5,376 KB
testcase_25 AC 2 ms
5,376 KB
testcase_26 AC 2 ms
5,376 KB
testcase_27 AC 2 ms
5,376 KB
testcase_28 AC 2 ms
5,376 KB
testcase_29 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

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)continue;
			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