結果

問題 No.1522 Unfairness
ユーザー googol_S0googol_S0
提出日時 2021-05-28 20:35:12
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 363 ms / 2,000 ms
コード長 397 bytes
コンパイル時間 243 ms
コンパイル使用メモリ 81,972 KB
実行使用メモリ 136,576 KB
最終ジャッジ日時 2024-04-29 21:53:44
合計ジャッジ時間 5,468 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
51,712 KB
testcase_01 AC 40 ms
52,224 KB
testcase_02 AC 40 ms
51,968 KB
testcase_03 AC 140 ms
92,800 KB
testcase_04 AC 78 ms
71,040 KB
testcase_05 AC 66 ms
68,224 KB
testcase_06 AC 53 ms
62,848 KB
testcase_07 AC 177 ms
91,008 KB
testcase_08 AC 167 ms
90,532 KB
testcase_09 AC 58 ms
65,408 KB
testcase_10 AC 99 ms
83,712 KB
testcase_11 AC 68 ms
67,968 KB
testcase_12 AC 119 ms
88,576 KB
testcase_13 AC 228 ms
113,536 KB
testcase_14 AC 68 ms
68,864 KB
testcase_15 AC 353 ms
136,448 KB
testcase_16 AC 363 ms
136,320 KB
testcase_17 AC 351 ms
136,192 KB
testcase_18 AC 361 ms
136,576 KB
testcase_19 AC 350 ms
136,192 KB
testcase_20 AC 287 ms
136,064 KB
testcase_21 AC 41 ms
52,096 KB
testcase_22 AC 39 ms
52,096 KB
testcase_23 AC 41 ms
52,992 KB
testcase_24 AC 62 ms
66,688 KB
testcase_25 AC 45 ms
58,112 KB
testcase_26 AC 55 ms
63,744 KB
testcase_27 AC 39 ms
51,968 KB
testcase_28 AC 44 ms
57,856 KB
testcase_29 AC 59 ms
65,280 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,M=map(int,input().split())
A=sorted(map(int,input().split()))
W=[0]*(N-1)
V=[0]*(N-1)
for i in range(N-1):
  W[i]=A[i+1]-A[i]
  V[i]=A[i+1]
INF=-(10**12)
DP=[[INF]*(M+1) for i in range(N)]
DP[0][0]=0
for i in range(N-1):
  for j in range(M+1):
    DP[i+1][j]=max(DP[i+1][j],DP[i][j])
    if j+W[i]<=M:
      DP[min(N-1,i+2)][j+W[i]]=max(DP[min(N-1,i+2)][j+W[i]],DP[i][j]+V[i])
print(max(DP[-1]))
0