結果

問題 No.1522 Unfairness
ユーザー roarisroaris
提出日時 2021-05-31 02:48:51
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 425 ms / 2,000 ms
コード長 478 bytes
コンパイル時間 300 ms
コンパイル使用メモリ 87,216 KB
実行使用メモリ 145,544 KB
最終ジャッジ日時 2023-08-12 07:30:21
合計ジャッジ時間 7,217 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 93 ms
71,636 KB
testcase_01 AC 91 ms
71,616 KB
testcase_02 AC 92 ms
71,732 KB
testcase_03 AC 194 ms
96,264 KB
testcase_04 AC 125 ms
78,048 KB
testcase_05 AC 126 ms
77,888 KB
testcase_06 AC 110 ms
77,888 KB
testcase_07 AC 249 ms
100,172 KB
testcase_08 AC 231 ms
99,588 KB
testcase_09 AC 113 ms
77,884 KB
testcase_10 AC 142 ms
78,068 KB
testcase_11 AC 125 ms
78,192 KB
testcase_12 AC 162 ms
78,336 KB
testcase_13 AC 282 ms
116,828 KB
testcase_14 AC 127 ms
78,444 KB
testcase_15 AC 411 ms
145,180 KB
testcase_16 AC 413 ms
145,408 KB
testcase_17 AC 425 ms
145,212 KB
testcase_18 AC 414 ms
145,412 KB
testcase_19 AC 416 ms
145,544 KB
testcase_20 AC 389 ms
145,196 KB
testcase_21 AC 93 ms
71,832 KB
testcase_22 AC 94 ms
71,544 KB
testcase_23 AC 93 ms
71,484 KB
testcase_24 AC 112 ms
77,528 KB
testcase_25 AC 102 ms
77,284 KB
testcase_26 AC 111 ms
77,340 KB
testcase_27 AC 91 ms
71,672 KB
testcase_28 AC 101 ms
77,160 KB
testcase_29 AC 110 ms
77,604 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
from collections import *

N, M = map(int, input().split())
A = list(map(int, input().split()))
A.sort(reverse=True)
dp = [[0]*(M+1) for _ in range(N+1)]

for i in range(1, N+1):
    for j in range(M+1):
        dp[i][j] = max(dp[i][j], dp[i-1][j])
    
    if i>=2:
        for j in range(M+1):
            k = j+A[i-2]-A[i-1]
            
            if k<=M:
                dp[i][k] = max(dp[i][k], dp[i-2][j]+A[i-2])

print(max(dp[N]))
0