Submission #76466224
Source Code Expand
import heapq
from collections import defaultdict
N, K, M = map(int, input().split())
stones = defaultdict(list)
for i in range(N):
a, b = map(int, input().split())
heapq.heappush(stones[a], -b)
color_heap = []
for c in stones:
heapq.heappush(color_heap, (stones[c][0], c))
ans = 0
for _ in range(M):
_, c = heapq.heappop(color_heap)
ans += -heapq.heappop(stones[c])
rest = []
for h in stones.values():
rest.extend(h)
heapq.heapify(rest)
for _ in range(K - M):
ans += -heapq.heappop(rest)
print(ans)
Submission Info
| Submission Time | |
|---|---|
| Task | C - Variety |
| User | Yoshi03 |
| Language | Python (PyPy 3.11-v7.3.20) |
| Score | 300 |
| Code Size | 556 Byte |
| Status | AC |
| Exec Time | 420 ms |
| Memory | 165884 KiB |
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 300 / 300 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | sample-01.txt, sample-02.txt, sample-03.txt |
| All | 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, 23.txt, sample-01.txt, sample-02.txt, sample-03.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 04.txt | AC | 61 ms | 95580 KiB |
| 05.txt | AC | 263 ms | 118836 KiB |
| 06.txt | AC | 331 ms | 165428 KiB |
| 07.txt | AC | 306 ms | 135364 KiB |
| 08.txt | AC | 63 ms | 96004 KiB |
| 09.txt | AC | 74 ms | 107912 KiB |
| 10.txt | AC | 105 ms | 109848 KiB |
| 11.txt | AC | 245 ms | 123956 KiB |
| 12.txt | AC | 407 ms | 143016 KiB |
| 13.txt | AC | 420 ms | 146868 KiB |
| 14.txt | AC | 420 ms | 145316 KiB |
| 15.txt | AC | 382 ms | 137176 KiB |
| 16.txt | AC | 350 ms | 136680 KiB |
| 17.txt | AC | 373 ms | 137160 KiB |
| 18.txt | AC | 369 ms | 132536 KiB |
| 19.txt | AC | 403 ms | 138392 KiB |
| 20.txt | AC | 381 ms | 138100 KiB |
| 21.txt | AC | 360 ms | 152272 KiB |
| 22.txt | AC | 335 ms | 165884 KiB |
| 23.txt | AC | 382 ms | 141228 KiB |
| sample-01.txt | AC | 65 ms | 95820 KiB |
| sample-02.txt | AC | 64 ms | 95860 KiB |
| sample-03.txt | AC | 63 ms | 95600 KiB |