結果
| 問題 |
No.448 ゆきこーだーの雨と雪 (3)
|
| ユーザー |
gew1fw
|
| 提出日時 | 2025-06-12 19:08:20 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 856 bytes |
| コンパイル時間 | 179 ms |
| コンパイル使用メモリ | 81,860 KB |
| 実行使用メモリ | 100,872 KB |
| 最終ジャッジ日時 | 2025-06-12 19:08:44 |
| 合計ジャッジ時間 | 16,960 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 11 WA * 24 |
ソースコード
import bisect
n, k = map(int, input().split())
tasks = []
for _ in range(n):
t, d = map(int, input().split())
tasks.append((t, d))
# Sort tasks by descending D, then ascending T
tasks.sort(key=lambda x: (-x[1], x[0]))
scheduled = []
added_times = set()
for t, d in tasks:
# Check if this task can be added
low = t - k + 1
high = t + k - 1
# Find the left and right positions in the scheduled list
left = bisect.bisect_left(scheduled, low)
right = bisect.bisect_right(scheduled, high)
if left == right:
# No existing tasks in the range [low, high]
bisect.insort(scheduled, t)
added_times.add(t)
# Collect all tasks not in scheduled
max_d = 0
sum_d = 0
for t, d in tasks:
if t not in added_times:
if d > max_d:
max_d = d
sum_d += d
print(max_d)
print(sum_d)
gew1fw