結果
| 問題 |
No.1583 Building Blocks
|
| コンテスト | |
| ユーザー |
tamato
|
| 提出日時 | 2021-07-02 22:30:18 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 68 ms / 2,000 ms |
| コード長 | 662 bytes |
| コンパイル時間 | 176 ms |
| コンパイル使用メモリ | 82,320 KB |
| 実行使用メモリ | 69,120 KB |
| 最終ジャッジ日時 | 2024-09-14 02:47:50 |
| 合計ジャッジ時間 | 3,702 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 43 |
ソースコード
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()
tamato