結果

問題 No.1583 Building Blocks
コンテスト
ユーザー tamato
提出日時 2021-07-02 22:24:41
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
WA  
実行時間 -
コード長 529 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,588 ms
コンパイル使用メモリ 85,380 KB
実行使用メモリ 64,932 KB
最終ジャッジ日時 2026-03-18 23:40:03
合計ジャッジ時間 4,041 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 25 WA * 18
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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)
        else:
            LIS[j] = min(LIS[j], LIS[j-1] + w)
    print(len(LIS) - 1)


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