結果
問題 |
No.2957 Combo Deck Builder
|
ユーザー |
|
提出日時 | 2025-01-19 01:43:19 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,319 bytes |
コンパイル時間 | 719 ms |
コンパイル使用メモリ | 82,048 KB |
実行使用メモリ | 150,184 KB |
最終ジャッジ日時 | 2025-01-19 01:43:50 |
合計ジャッジ時間 | 29,260 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 11 WA * 25 TLE * 2 |
ソースコード
## https://yukicoder.me/problems/no/2957 import heapq from collections import deque def main(): N = int(input()) cxy = [] for _ in range(N): c, x, y = map(int, input().split()) cxy.append((c, x, y)) c_map = {} queue = [] for i in range(N): c, x, y = cxy[i] d = x - y heapq.heappush(queue, (d, i)) if c not in c_map: c_map[c] = [] c_map[c].append(i) used = [False] * N answer = 0 for _, _,y in cxy: answer += y q = deque() for c in range(N): if c in c_map: for j in c_map[c]: _, x, y = cxy[j] if not used[j]: used[j] = True q.append(x - y) while len(queue) > 0 and used[queue[0][1]]: heapq.heappop(queue) if len(queue) > 0: if queue[0][0] <= 0: _, j = heapq.heappop(queue) used[j] = True elif len(q) > 0: d = q.popleft() answer += d else: _, j = heapq.heappop(queue) used[j] = True else: d = q.popleft() answer += d print(answer) if __name__ == "__main__": main()