Submission #67732677


Source Code Expand

N, M = map(int, input().split())
operations = [list(map(int, input().split())) for _ in range(M)]
operations.sort(reverse=True, key = lambda x: (x[0]-x[1],x[0]))

ans = 0
while operations:
    op = operations.pop()
    a, b = op
    if a <= N:
        num = (N - b - 1) // (a - b) 
        ans += num
        N -= num * (a - b)
    if N == a:
        ans += 1
        N -= a - b
    
print(ans)

Submission Info

Submission Time
Task D - Get Many Stickers
User myuuuu
Language Python (PyPy 3.10-v7.3.12)
Score 400
Code Size 410 Byte
Status AC
Exec Time 586 ms
Memory 118372 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 3
AC × 31
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 57 ms 76612 KiB
00_sample_01.txt AC 58 ms 76416 KiB
00_sample_02.txt AC 59 ms 76536 KiB
01_random_00.txt AC 283 ms 99316 KiB
01_random_01.txt AC 389 ms 106628 KiB
01_random_02.txt AC 463 ms 111140 KiB
01_random_03.txt AC 559 ms 117472 KiB
01_random_04.txt AC 538 ms 117656 KiB
01_random_05.txt AC 557 ms 117488 KiB
02_random2_00.txt AC 567 ms 117680 KiB
02_random2_01.txt AC 575 ms 118056 KiB
02_random2_02.txt AC 575 ms 118344 KiB
02_random2_03.txt AC 566 ms 117884 KiB
02_random2_04.txt AC 586 ms 118116 KiB
02_random2_05.txt AC 565 ms 117968 KiB
02_random2_06.txt AC 564 ms 117768 KiB
02_random2_07.txt AC 582 ms 118068 KiB
02_random2_08.txt AC 584 ms 118372 KiB
02_random2_09.txt AC 550 ms 117756 KiB
02_random2_10.txt AC 556 ms 117120 KiB
02_random2_11.txt AC 558 ms 117404 KiB
03_random3_00.txt AC 547 ms 117568 KiB
03_random3_01.txt AC 552 ms 117024 KiB
03_random3_02.txt AC 542 ms 117712 KiB
03_random3_03.txt AC 545 ms 117052 KiB
03_random3_04.txt AC 558 ms 117924 KiB
04_handmade_00.txt AC 191 ms 116300 KiB
04_handmade_01.txt AC 193 ms 115872 KiB
04_handmade_02.txt AC 58 ms 76720 KiB
04_handmade_03.txt AC 59 ms 76580 KiB
04_handmade_04.txt AC 561 ms 117784 KiB