結果

問題 No.1522 Unfairness
ユーザー kotatsugamekotatsugame
提出日時 2021-05-28 20:52:27
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 64 ms / 2,000 ms
コード長 426 bytes
コンパイル時間 616 ms
コンパイル使用メモリ 70,248 KB
実行使用メモリ 38,656 KB
最終ジャッジ日時 2024-04-29 21:54:05
合計ジャッジ時間 2,153 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 20 ms
14,848 KB
testcase_04 AC 9 ms
8,704 KB
testcase_05 AC 8 ms
8,576 KB
testcase_06 AC 12 ms
12,672 KB
testcase_07 AC 26 ms
17,408 KB
testcase_08 AC 36 ms
26,880 KB
testcase_09 AC 8 ms
8,064 KB
testcase_10 AC 17 ms
14,976 KB
testcase_11 AC 7 ms
7,680 KB
testcase_12 AC 14 ms
11,136 KB
testcase_13 AC 38 ms
26,112 KB
testcase_14 AC 7 ms
6,144 KB
testcase_15 AC 64 ms
38,656 KB
testcase_16 AC 64 ms
38,656 KB
testcase_17 AC 63 ms
38,656 KB
testcase_18 AC 64 ms
38,656 KB
testcase_19 AC 63 ms
38,528 KB
testcase_20 AC 64 ms
38,528 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 3 ms
5,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:7:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    7 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<algorithm>
using namespace std;
int N,M;
int A[3000];
int dp[3001][3001];
main()
{
	cin>>N>>M;
	for(int i=0;i<N;i++)cin>>A[i];
	sort(A,A+N);
	reverse(A,A+N);
	for(int i=0;i<N;i++)
	{
		for(int j=0;j<=M;j++)
		{
			dp[i+1][j]=max(dp[i+1][j],dp[i][j]);
			if(i+1<N&&j+A[i]-A[i+1]<=M)
			{
				int nj=j+A[i]-A[i+1];
				dp[i+2][nj]=max(dp[i+2][nj],dp[i][j]+A[i]);
			}
		}
	}
	cout<<dp[N][M]<<endl;
}
0