Submission #69325036


Source Code Expand

n, K = map(int, input().split())
ABC = [tuple(map(int, input().split())) for _ in range(n)]
order = sorted(range(n), key=lambda x:ABC[x][0])

import heapq
que = []
tot = 0
t = 0
answer = [0]*n
for i in order:
  a, b, c = ABC[i]
  while tot+c>K:
    t, num = heapq.heappop(que)
    tot -= num
  t = max(t, a)
  answer[i] = t
  heapq.heappush(que, (t+b, c))
  tot += c

print(*answer, sep='\n')

    

Submission Info

Submission Time
Task D - Long Waiting
User uparupaaa
Language Python (PyPy 3.10-v7.3.12)
Score 400
Code Size 421 Byte
Status AC
Exec Time 388 ms
Memory 144704 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 3
AC × 17
Set Name Test Cases
Sample 00-sample-01.txt, 00-sample-02.txt, 00-sample-03.txt
All 00-sample-01.txt, 00-sample-02.txt, 00-sample-03.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt, 01-11.txt, 01-12.txt, 01-13.txt, 01-14.txt
Case Name Status Exec Time Memory
00-sample-01.txt AC 57 ms 76612 KiB
00-sample-02.txt AC 58 ms 76376 KiB
00-sample-03.txt AC 57 ms 76636 KiB
01-01.txt AC 181 ms 99400 KiB
01-02.txt AC 299 ms 132416 KiB
01-03.txt AC 155 ms 106424 KiB
01-04.txt AC 145 ms 98996 KiB
01-05.txt AC 362 ms 144704 KiB
01-06.txt AC 335 ms 141728 KiB
01-07.txt AC 153 ms 92804 KiB
01-08.txt AC 388 ms 143552 KiB
01-09.txt AC 309 ms 133876 KiB
01-10.txt AC 359 ms 134500 KiB
01-11.txt AC 348 ms 134100 KiB
01-12.txt AC 359 ms 134300 KiB
01-13.txt AC 310 ms 134068 KiB
01-14.txt AC 332 ms 134396 KiB