Submission #67745633
Source Code Expand
Copy
n, m = map(int, input().split())a = []b = []for _ in range(m):x, y = map(int, input().split())a.append(x)b.append(y)C = sorted(zip(a, b), key=lambda x: (x[1] - x[0], x[1] / x[0]), reverse=True)full = nemp = 0answer = 0while True:emp += fullfull = 0ex = Falsefor A, B in C:if emp >= A:times = emp // Aemp -= times * Afull += times * Banswer += times
n, m = map(int, input().split())
a = []
b = []
for _ in range(m):
x, y = map(int, input().split())
a.append(x)
b.append(y)
C = sorted(zip(a, b), key=lambda x: (x[1] - x[0], x[1] / x[0]), reverse=True)
full = n
emp = 0
answer = 0
while True:
emp += full
full = 0
ex = False
for A, B in C:
if emp >= A:
times = emp // A
emp -= times * A
full += times * B
answer += times
ex = True
break
if not ex:
break
print(answer)
Submission Info
| Submission Time | |
|---|---|
| Task | D - Get Many Stickers |
| User | practicejoi |
| Language | Python (PyPy 3.10-v7.3.12) |
| Score | 0 |
| Code Size | 560 Byte |
| Status | TLE |
| Exec Time | 2213 ms |
| Memory | 127716 KiB |
Judge Result
| Set Name | Sample | All | ||||||
|---|---|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 0 / 400 | ||||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt |
| All | 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_random_00.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 02_random2_00.txt, 02_random2_01.txt, 02_random2_02.txt, 02_random2_03.txt, 02_random2_04.txt, 02_random2_05.txt, 02_random2_06.txt, 02_random2_07.txt, 02_random2_08.txt, 02_random2_09.txt, 02_random2_10.txt, 02_random2_11.txt, 03_random3_00.txt, 03_random3_01.txt, 03_random3_02.txt, 03_random3_03.txt, 03_random3_04.txt, 04_handmade_00.txt, 04_handmade_01.txt, 04_handmade_02.txt, 04_handmade_03.txt, 04_handmade_04.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 00_sample_00.txt | AC | 58 ms | 76668 KiB |
| 00_sample_01.txt | AC | 57 ms | 76616 KiB |
| 00_sample_02.txt | AC | 58 ms | 76288 KiB |
| 01_random_00.txt | AC | 291 ms | 99556 KiB |
| 01_random_01.txt | AC | 386 ms | 106424 KiB |
| 01_random_02.txt | AC | 449 ms | 110428 KiB |
| 01_random_03.txt | AC | 518 ms | 124660 KiB |
| 01_random_04.txt | AC | 520 ms | 124668 KiB |
| 01_random_05.txt | AC | 503 ms | 124920 KiB |
| 02_random2_00.txt | TLE | 2213 ms | 122252 KiB |
| 02_random2_01.txt | TLE | 2213 ms | 121772 KiB |
| 02_random2_02.txt | TLE | 2213 ms | 121632 KiB |
| 02_random2_03.txt | AC | 491 ms | 119924 KiB |
| 02_random2_04.txt | AC | 490 ms | 120144 KiB |
| 02_random2_05.txt | AC | 499 ms | 119464 KiB |
| 02_random2_06.txt | TLE | 2213 ms | 122128 KiB |
| 02_random2_07.txt | TLE | 2213 ms | 122920 KiB |
| 02_random2_08.txt | TLE | 2213 ms | 122520 KiB |
| 02_random2_09.txt | TLE | 2213 ms | 120436 KiB |
| 02_random2_10.txt | TLE | 2213 ms | 120232 KiB |
| 02_random2_11.txt | TLE | 2213 ms | 120220 KiB |
| 03_random3_00.txt | TLE | 2213 ms | 120112 KiB |
| 03_random3_01.txt | TLE | 2213 ms | 120596 KiB |
| 03_random3_02.txt | TLE | 2213 ms | 120380 KiB |
| 03_random3_03.txt | TLE | 2213 ms | 120460 KiB |
| 03_random3_04.txt | TLE | 2213 ms | 120836 KiB |
| 04_handmade_00.txt | AC | 167 ms | 127716 KiB |
| 04_handmade_01.txt | AC | 167 ms | 127520 KiB |
| 04_handmade_02.txt | AC | 54 ms | 76460 KiB |
| 04_handmade_03.txt | AC | 55 ms | 76292 KiB |
| 04_handmade_04.txt | TLE | 2213 ms | 120516 KiB |