結果

問題 No.1583 Building Blocks
ユーザー ygd.ygd.
提出日時 2021-07-02 23:29:49
言語 PyPy3
(7.3.15)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 681 bytes
コンパイル時間 2,181 ms
コンパイル使用メモリ 86,860 KB
実行使用メモリ 77,748 KB
最終ジャッジ日時 2023-10-12 03:04:39
合計ジャッジ時間 7,470 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 93 ms
71,732 KB
testcase_01 AC 89 ms
71,556 KB
testcase_02 AC 91 ms
71,648 KB
testcase_03 AC 115 ms
77,216 KB
testcase_04 AC 102 ms
76,012 KB
testcase_05 AC 97 ms
75,972 KB
testcase_06 AC 112 ms
77,148 KB
testcase_07 AC 115 ms
77,596 KB
testcase_08 AC 101 ms
75,960 KB
testcase_09 AC 123 ms
77,696 KB
testcase_10 AC 98 ms
76,264 KB
testcase_11 AC 87 ms
71,540 KB
testcase_12 AC 108 ms
77,524 KB
testcase_13 AC 113 ms
77,516 KB
testcase_14 AC 107 ms
77,328 KB
testcase_15 AC 111 ms
77,692 KB
testcase_16 AC 110 ms
77,400 KB
testcase_17 AC 110 ms
77,500 KB
testcase_18 AC 106 ms
77,404 KB
testcase_19 AC 130 ms
77,748 KB
testcase_20 AC 112 ms
77,052 KB
testcase_21 AC 114 ms
77,476 KB
testcase_22 AC 114 ms
77,424 KB
testcase_23 AC 105 ms
75,964 KB
testcase_24 AC 126 ms
77,584 KB
testcase_25 AC 94 ms
71,724 KB
testcase_26 AC 128 ms
77,384 KB
testcase_27 AC 115 ms
77,460 KB
testcase_28 AC 128 ms
77,724 KB
testcase_29 AC 112 ms
77,352 KB
testcase_30 AC 105 ms
75,996 KB
testcase_31 AC 117 ms
77,432 KB
testcase_32 AC 110 ms
77,292 KB
testcase_33 AC 121 ms
77,340 KB
testcase_34 AC 91 ms
71,700 KB
testcase_35 AC 111 ms
77,404 KB
testcase_36 AC 125 ms
77,392 KB
testcase_37 AC 108 ms
77,228 KB
testcase_38 AC 92 ms
71,676 KB
testcase_39 AC 94 ms
71,372 KB
testcase_40 AC 93 ms
71,632 KB
testcase_41 AC 94 ms
71,740 KB
testcase_42 AC 94 ms
71,744 KB
testcase_43 AC 95 ms
71,560 KB
testcase_44 AC 97 ms
71,576 KB
testcase_45 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import copy

def main():
    N = int(input()); INF = float("inf")
    Z = []
    for i in range(N):
        w,s = map(int,input().split())
        Z.append((w,s))
    Z.sort(key = lambda x: x[0] + x[1])
    #dp[i][j]: i個目まで見てj個使った時の最小の重さ
    dp = [INF]*(N+1)
    dp[0] = 0
    for i in range(N):
        p = copy.copy(dp) #i個目を使わないときをコピー
        p,dp = dp,p
        w,s = Z[i]
        for j in range(N):
            if dp[j] <= s:
                dp[j+1] = min(dp[j+1], p[j] + w)
    #print(dp)
    for j in reversed(range(N+1)):
        if dp[j] != INF:
            print(j);exit()

if __name__ == '__main__':
    main()
0