結果

問題 No.1522 Unfairness
ユーザー shotoyooshotoyoo
提出日時 2021-05-28 21:35:28
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 321 ms / 2,000 ms
コード長 633 bytes
コンパイル時間 293 ms
コンパイル使用メモリ 87,184 KB
実行使用メモリ 148,924 KB
最終ジャッジ日時 2023-08-12 07:27:21
合計ジャッジ時間 6,099 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
71,340 KB
testcase_01 AC 68 ms
71,404 KB
testcase_02 AC 68 ms
71,424 KB
testcase_03 AC 164 ms
96,188 KB
testcase_04 AC 113 ms
82,148 KB
testcase_05 AC 95 ms
77,044 KB
testcase_06 AC 83 ms
76,692 KB
testcase_07 AC 207 ms
105,340 KB
testcase_08 AC 211 ms
105,056 KB
testcase_09 AC 90 ms
76,888 KB
testcase_10 AC 126 ms
85,700 KB
testcase_11 AC 107 ms
80,728 KB
testcase_12 AC 146 ms
89,552 KB
testcase_13 AC 222 ms
114,292 KB
testcase_14 AC 111 ms
80,928 KB
testcase_15 AC 321 ms
148,924 KB
testcase_16 AC 321 ms
148,740 KB
testcase_17 AC 312 ms
148,636 KB
testcase_18 AC 314 ms
148,532 KB
testcase_19 AC 317 ms
148,496 KB
testcase_20 AC 297 ms
148,200 KB
testcase_21 AC 71 ms
71,604 KB
testcase_22 AC 69 ms
71,460 KB
testcase_23 AC 73 ms
71,136 KB
testcase_24 AC 106 ms
77,628 KB
testcase_25 AC 81 ms
76,072 KB
testcase_26 AC 101 ms
77,644 KB
testcase_27 AC 71 ms
71,464 KB
testcase_28 AC 77 ms
76,136 KB
testcase_29 AC 102 ms
77,732 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