結果

問題 No.1522 Unfairness
ユーザー googol_S0googol_S0
提出日時 2021-05-28 20:35:12
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 389 ms / 2,000 ms
コード長 397 bytes
コンパイル時間 1,930 ms
コンパイル使用メモリ 86,920 KB
実行使用メモリ 148,212 KB
最終ジャッジ日時 2023-08-12 07:25:05
合計ジャッジ時間 6,729 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
71,056 KB
testcase_01 AC 74 ms
71,128 KB
testcase_02 AC 74 ms
71,056 KB
testcase_03 AC 168 ms
92,332 KB
testcase_04 AC 106 ms
76,272 KB
testcase_05 AC 98 ms
76,704 KB
testcase_06 AC 85 ms
76,632 KB
testcase_07 AC 214 ms
104,484 KB
testcase_08 AC 209 ms
104,296 KB
testcase_09 AC 90 ms
76,788 KB
testcase_10 AC 126 ms
84,892 KB
testcase_11 AC 98 ms
76,384 KB
testcase_12 AC 144 ms
89,480 KB
testcase_13 AC 255 ms
112,876 KB
testcase_14 AC 99 ms
76,464 KB
testcase_15 AC 387 ms
148,140 KB
testcase_16 AC 388 ms
147,996 KB
testcase_17 AC 368 ms
135,628 KB
testcase_18 AC 389 ms
148,212 KB
testcase_19 AC 378 ms
135,512 KB
testcase_20 AC 302 ms
135,580 KB
testcase_21 AC 73 ms
71,312 KB
testcase_22 AC 72 ms
71,216 KB
testcase_23 AC 73 ms
71,200 KB
testcase_24 AC 93 ms
76,312 KB
testcase_25 AC 78 ms
75,752 KB
testcase_26 AC 88 ms
75,876 KB
testcase_27 AC 72 ms
71,192 KB
testcase_28 AC 75 ms
75,972 KB
testcase_29 AC 91 ms
75,916 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