結果
問題 |
No.448 ゆきこーだーの雨と雪 (3)
|
ユーザー |
![]() |
提出日時 | 2020-03-20 01:07:31 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 905 ms / 2,000 ms |
コード長 | 1,098 bytes |
コンパイル時間 | 244 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 78,532 KB |
最終ジャッジ日時 | 2024-12-14 03:43:29 |
合計ジャッジ時間 | 31,052 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 35 |
ソースコード
#!/usr/bin/ python3.8 import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines import numpy as np N, K = map(int, readline().split()) TD = np.array(read().split(), np.int64) T = TD[::2] D = TD[1::2] INF = 2 * 10 ** 9 T = np.concatenate([[-INF], T]) D = np.concatenate([[0], D]) def find_X(): def test(X): # X 以上をさぼれる A = T[D >= X] if not len(A): return True return np.all(np.diff(A) >= K) left = 0 right = 10 ** 9 + 10 while left + 1 < right: x = (left + right) // 2 if test(x): right = x else: left = x return left X = find_X() I = np.searchsorted(T, T - K, side='right') - 1 last_take = 0 D = D.tolist() I = I.tolist() dp = [0] * len(D) dp_cum = [0] * len(D) for n, (i, x) in enumerate(zip(I[1:], D[1:]), 1): if i >= last_take: dp[n] = dp_cum[i] + x dp_cum[n] = max(dp_cum[n - 1], dp[n]) if x > X: last_take = n yuki = dp_cum[-1] answer = sum(D) - yuki print(X) print(answer)