Submission #73777614
Source Code Expand
def main():
H,W,N = map(int,input().split())
choco_w = []
choco_h = []
for _ in range(N):
h,w = map(int,input().split())
choco_w.append(w)
choco_h.append(h)
ord_h = [i for i in range(N)]
ord_h.sort(key = lambda x:-choco_h[x])
ord_w = [i for i in range(N)]
ord_w.sort(key = lambda x:-choco_w[x])
ans = [0 for _ in range(N)]
is_used = [False for _ in range(N)]
remain = N
hp = 0
wp = 0
while remain > 0:
while hp < N and is_used[ord_h[hp]]:hp += 1
while wp < N and is_used[ord_w[wp]]:wp += 1
i = ord_h[hp] if hp < N and choco_h[ord_h[hp]] == H else ord_w[wp]
ans_x = H - choco_h[i] + 1
ans_y = W - choco_w[i] + 1
is_used[i] = True
if choco_h[i] == H:
W -= choco_w[i]
else:
H -= choco_h[i]
ans[i] = (ans_x,ans_y)
remain -= 1
for line in ans:
print(*line)
main()
Submission Info
| Submission Time | |
|---|---|
| Task | D - Reconstruct Chocolate |
| User | black9 |
| Language | Python (PyPy 3.11-v7.3.20) |
| Score | 425 |
| Code Size | 1018 Byte |
| Status | AC |
| Exec Time | 775 ms |
| Memory | 145988 KiB |
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 425 / 425 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | 00_sample_01.txt, 00_sample_02.txt |
| All | 00_sample_01.txt, 00_sample_02.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 02_biased_cut_01.txt, 02_biased_cut_02.txt, 02_biased_cut_03.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 00_sample_01.txt | AC | 53 ms | 79828 KiB |
| 00_sample_02.txt | AC | 53 ms | 80152 KiB |
| 01_random_01.txt | AC | 737 ms | 145300 KiB |
| 01_random_02.txt | AC | 775 ms | 145648 KiB |
| 01_random_03.txt | AC | 713 ms | 145272 KiB |
| 01_random_04.txt | AC | 725 ms | 145088 KiB |
| 01_random_05.txt | AC | 669 ms | 145244 KiB |
| 01_random_06.txt | AC | 685 ms | 145368 KiB |
| 01_random_07.txt | AC | 747 ms | 145184 KiB |
| 01_random_08.txt | AC | 734 ms | 145612 KiB |
| 01_random_09.txt | AC | 718 ms | 145044 KiB |
| 01_random_10.txt | AC | 696 ms | 145304 KiB |
| 01_random_11.txt | AC | 689 ms | 145088 KiB |
| 01_random_12.txt | AC | 726 ms | 145988 KiB |
| 01_random_13.txt | AC | 724 ms | 145368 KiB |
| 01_random_14.txt | AC | 724 ms | 145148 KiB |
| 02_biased_cut_01.txt | AC | 631 ms | 143916 KiB |
| 02_biased_cut_02.txt | AC | 627 ms | 143364 KiB |
| 02_biased_cut_03.txt | AC | 740 ms | 145504 KiB |