結果

問題 No.1522 Unfairness
ユーザー tktk_snsntktk_snsn
提出日時 2021-05-29 11:06:39
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 546 ms / 2,000 ms
コード長 459 bytes
コンパイル時間 168 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 44,480 KB
最終ジャッジ日時 2024-04-29 21:58:39
合計ジャッジ時間 18,436 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 496 ms
43,956 KB
testcase_01 AC 497 ms
43,832 KB
testcase_02 AC 486 ms
44,480 KB
testcase_03 AC 506 ms
44,088 KB
testcase_04 AC 504 ms
44,224 KB
testcase_05 AC 508 ms
44,344 KB
testcase_06 AC 512 ms
44,408 KB
testcase_07 AC 521 ms
44,344 KB
testcase_08 AC 518 ms
44,216 KB
testcase_09 AC 503 ms
44,340 KB
testcase_10 AC 507 ms
44,096 KB
testcase_11 AC 511 ms
44,088 KB
testcase_12 AC 504 ms
44,348 KB
testcase_13 AC 513 ms
43,964 KB
testcase_14 AC 502 ms
44,348 KB
testcase_15 AC 535 ms
43,960 KB
testcase_16 AC 529 ms
44,344 KB
testcase_17 AC 543 ms
43,956 KB
testcase_18 AC 544 ms
44,224 KB
testcase_19 AC 546 ms
44,356 KB
testcase_20 AC 530 ms
44,228 KB
testcase_21 AC 504 ms
44,348 KB
testcase_22 AC 513 ms
44,220 KB
testcase_23 AC 501 ms
44,344 KB
testcase_24 AC 504 ms
44,348 KB
testcase_25 AC 505 ms
43,964 KB
testcase_26 AC 507 ms
44,220 KB
testcase_27 AC 506 ms
43,960 KB
testcase_28 AC 504 ms
44,344 KB
testcase_29 AC 509 ms
44,120 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import numpy as np
N, P = map(int, input().split())
A = list(map(int, input().split()))
A.sort()

dp = np.zeros(P+1, dtype=np.int64)
ndp = np.zeros_like(dp)
for i in range(1, N):
    get = A[i]
    pena = A[i] - A[i-1]

    newDP = np.copy(dp)
    if pena:
        newDP[pena:] = np.maximum(newDP[pena:], dp[:-pena] + get)
    else:
        newDP += get

    np.maximum(dp, ndp, out=ndp)
    dp, ndp = ndp, newDP

np.maximum(dp, ndp, out=ndp)
print(ndp.max())
0