結果
問題 |
No.1583 Building Blocks
|
ユーザー |
![]() |
提出日時 | 2021-07-02 22:28:07 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 654 bytes |
コンパイル時間 | 163 ms |
コンパイル使用メモリ | 82,916 KB |
実行使用メモリ | 65,920 KB |
最終ジャッジ日時 | 2024-06-29 12:16:19 |
合計ジャッジ時間 | 3,984 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 18 WA * 25 |
ソースコード
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(1, j): LIS[k] = min(LIS[k], LIS[k-1] + w) else: for k in range(1, j+1): LIS[k] = min(LIS[k], LIS[k-1] + w) print(len(LIS) - 1) if __name__ == '__main__': main()