結果
問題 |
No.448 ゆきこーだーの雨と雪 (3)
|
ユーザー |
![]() |
提出日時 | 2025-03-31 17:50:35 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,196 bytes |
コンパイル時間 | 188 ms |
コンパイル使用メモリ | 82,256 KB |
実行使用メモリ | 132,892 KB |
最終ジャッジ日時 | 2025-03-31 17:51:50 |
合計ジャッジ時間 | 16,623 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 11 WA * 24 |
ソースコード
import bisect def main(): import sys input = sys.stdin.read data = input().split() idx = 0 n = int(data[idx]) idx += 1 k = int(data[idx]) idx += 1 tasks = [] for _ in range(n): t = int(data[idx]) idx += 1 d = int(data[idx]) idx += 1 tasks.append((t, d)) # Sort tasks by descending D, ascending T tasks.sort(key=lambda x: (-x[1], x[0])) y_list = [] selected = [] for t, d in tasks: idx_ins = bisect.bisect_left(y_list, t) ok = True # Check left neighbor if idx_ins > 0: if t - y_list[idx_ins - 1] < k: ok = False # Check right neighbor if idx_ins < len(y_list): if y_list[idx_ins] - t < k: ok = False if ok: bisect.insort(y_list, t) selected.append(t) # Collect Ame's tasks max_d = 0 total = 0 selected_set = set(selected) for t, d in tasks: if t not in selected_set: if d > max_d: max_d = d total += d print(max_d) print(total) if __name__ == '__main__': main()