結果

問題 No.1583 Building Blocks
ユーザー 👑 tamatotamato
提出日時 2021-07-02 22:30:18
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 98 ms / 2,000 ms
コード長 662 bytes
コンパイル時間 278 ms
コンパイル使用メモリ 87,404 KB
実行使用メモリ 76,844 KB
最終ジャッジ日時 2023-10-12 03:03:14
合計ジャッジ時間 5,916 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
71,880 KB
testcase_01 AC 79 ms
71,756 KB
testcase_02 AC 78 ms
71,692 KB
testcase_03 AC 93 ms
76,840 KB
testcase_04 AC 82 ms
76,008 KB
testcase_05 AC 77 ms
71,576 KB
testcase_06 AC 89 ms
76,692 KB
testcase_07 AC 89 ms
76,624 KB
testcase_08 AC 78 ms
71,516 KB
testcase_09 AC 91 ms
76,400 KB
testcase_10 AC 79 ms
71,656 KB
testcase_11 AC 78 ms
71,744 KB
testcase_12 AC 95 ms
76,520 KB
testcase_13 AC 97 ms
76,720 KB
testcase_14 AC 90 ms
76,820 KB
testcase_15 AC 92 ms
76,668 KB
testcase_16 AC 93 ms
76,756 KB
testcase_17 AC 96 ms
76,776 KB
testcase_18 AC 84 ms
76,248 KB
testcase_19 AC 98 ms
76,392 KB
testcase_20 AC 91 ms
76,580 KB
testcase_21 AC 91 ms
76,456 KB
testcase_22 AC 92 ms
76,676 KB
testcase_23 AC 82 ms
75,800 KB
testcase_24 AC 90 ms
76,808 KB
testcase_25 AC 76 ms
71,404 KB
testcase_26 AC 90 ms
76,396 KB
testcase_27 AC 86 ms
76,640 KB
testcase_28 AC 93 ms
76,680 KB
testcase_29 AC 86 ms
76,508 KB
testcase_30 AC 81 ms
75,948 KB
testcase_31 AC 89 ms
76,804 KB
testcase_32 AC 82 ms
76,600 KB
testcase_33 AC 94 ms
76,844 KB
testcase_34 AC 74 ms
71,712 KB
testcase_35 AC 88 ms
76,664 KB
testcase_36 AC 89 ms
76,500 KB
testcase_37 AC 78 ms
75,716 KB
testcase_38 AC 76 ms
71,696 KB
testcase_39 AC 76 ms
71,580 KB
testcase_40 AC 76 ms
71,668 KB
testcase_41 AC 79 ms
71,556 KB
testcase_42 AC 77 ms
71,836 KB
testcase_43 AC 75 ms
71,684 KB
testcase_44 AC 76 ms
71,656 KB
testcase_45 AC 74 ms
71,672 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 1000000007
eps = 10**-9


def main():
    import sys
    from bisect import bisect_left
    input = sys.stdin.readline

    N = int(input())
    WS = []
    for _ in range(N):
        WS.append(tuple(map(int, input().split())))
    WS.sort(key=lambda x: x[0] + x[1])

    LIS = [0]
    for w, s in WS:
        j = bisect_left(LIS, s+1)
        if j == len(LIS):
            LIS.append(LIS[-1] + w)
            for k in range(j-1, 0, -1):
                LIS[k] = min(LIS[k], LIS[k-1] + w)
        else:
            for k in range(j, 0, -1):
                LIS[k] = min(LIS[k], LIS[k-1] + w)
    print(len(LIS) - 1)


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