結果

問題 No.1522 Unfairness
ユーザー mkawa2mkawa2
提出日時 2023-12-26 00:25:32
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 154 ms / 2,000 ms
コード長 1,028 bytes
コンパイル時間 252 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 76,004 KB
最終ジャッジ日時 2023-12-26 00:25:36
合計ジャッジ時間 3,596 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,460 KB
testcase_01 AC 37 ms
53,460 KB
testcase_02 AC 37 ms
53,460 KB
testcase_03 AC 68 ms
75,720 KB
testcase_04 AC 53 ms
68,536 KB
testcase_05 AC 50 ms
64,548 KB
testcase_06 AC 44 ms
62,220 KB
testcase_07 AC 95 ms
75,832 KB
testcase_08 AC 72 ms
75,848 KB
testcase_09 AC 49 ms
62,476 KB
testcase_10 AC 58 ms
72,768 KB
testcase_11 AC 49 ms
66,456 KB
testcase_12 AC 56 ms
74,404 KB
testcase_13 AC 86 ms
75,992 KB
testcase_14 AC 47 ms
64,020 KB
testcase_15 AC 114 ms
75,992 KB
testcase_16 AC 113 ms
76,004 KB
testcase_17 AC 114 ms
75,992 KB
testcase_18 AC 112 ms
76,004 KB
testcase_19 AC 113 ms
75,992 KB
testcase_20 AC 154 ms
75,988 KB
testcase_21 AC 38 ms
53,460 KB
testcase_22 AC 37 ms
53,460 KB
testcase_23 AC 38 ms
53,460 KB
testcase_24 AC 47 ms
62,244 KB
testcase_25 AC 38 ms
53,460 KB
testcase_26 AC 45 ms
61,976 KB
testcase_27 AC 37 ms
53,460 KB
testcase_28 AC 38 ms
53,460 KB
testcase_29 AC 46 ms
61,972 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

# sys.setrecursionlimit(1000005)
# sys.set_int_max_str_digits(200005)
int1 = lambda x: int(x)-1
pDB = lambda *x: print(*x, end="\n", file=sys.stderr)
p2D = lambda x: print(*x, sep="\n", end="\n\n", file=sys.stderr)
def II(): return int(sys.stdin.readline())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
def SI(): return sys.stdin.readline().rstrip()

# dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
# inf = -1-(-1 << 31)
inf = -1-(-1 << 62)

# md = 10**9+7
md = 998244353

n,m=LI()
a=LI()
a.sort(reverse=True)

def chmax(i,val):
    if val>dp[i]:dp[i]=val

dp=[0]*(m+1)
p1=[0]*(m+1)
p2=[0]*(m+1)
for i in range(n-1):
    d=a[i]-a[i+1]
    dp,p1,p2=dp[:],dp,p1
    for j in range(d,m+1):
        chmax(j,p2[j-d]+a[i])

print(max(dp))
0