結果

問題 No.1522 Unfairness
ユーザー shotoyooshotoyoo
提出日時 2021-05-28 21:35:28
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 299 ms / 2,000 ms
コード長 633 bytes
コンパイル時間 188 ms
コンパイル使用メモリ 82,560 KB
実行使用メモリ 147,588 KB
最終ジャッジ日時 2024-04-29 21:55:40
合計ジャッジ時間 4,782 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
51,840 KB
testcase_01 AC 37 ms
52,224 KB
testcase_02 AC 37 ms
52,608 KB
testcase_03 AC 139 ms
93,568 KB
testcase_04 AC 83 ms
80,896 KB
testcase_05 AC 65 ms
70,784 KB
testcase_06 AC 54 ms
65,536 KB
testcase_07 AC 177 ms
104,064 KB
testcase_08 AC 184 ms
103,808 KB
testcase_09 AC 57 ms
66,688 KB
testcase_10 AC 96 ms
83,968 KB
testcase_11 AC 72 ms
72,704 KB
testcase_12 AC 121 ms
88,832 KB
testcase_13 AC 198 ms
114,816 KB
testcase_14 AC 78 ms
73,984 KB
testcase_15 AC 299 ms
147,588 KB
testcase_16 AC 294 ms
147,428 KB
testcase_17 AC 292 ms
147,456 KB
testcase_18 AC 292 ms
147,328 KB
testcase_19 AC 296 ms
147,328 KB
testcase_20 AC 265 ms
137,600 KB
testcase_21 AC 37 ms
52,736 KB
testcase_22 AC 37 ms
52,096 KB
testcase_23 AC 39 ms
52,864 KB
testcase_24 AC 72 ms
74,696 KB
testcase_25 AC 48 ms
62,464 KB
testcase_26 AC 67 ms
71,680 KB
testcase_27 AC 37 ms
52,224 KB
testcase_28 AC 47 ms
60,928 KB
testcase_29 AC 69 ms
73,600 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = lambda : sys.stdin.readline().rstrip()

sys.setrecursionlimit(2*10**5+10)
write = lambda x: sys.stdout.write(x+"\n")
debug = lambda x: sys.stderr.write(x+"\n")
writef = lambda x: print("{:.12f}".format(x))


n,m = list(map(int, input().split()))
a = list(map(int, input().split()))
a.sort(reverse=1)
dp = [[0]*(m+1) for _ in range(n+1)]
def chmax(i,j,v):
    dp[i][j] = max(dp[i][j], v)
for i in range(n):
    for j in range(m+1):
        v = dp[i][j]
        if i+2<=n:
            nj = j+a[i]-a[i+1]
            if nj<=m:
                chmax(i+2, nj, v+a[i])
        chmax(i+1,j, v)
ans = max(dp[n])
print(ans)
0