Submission #59390964
Source Code Expand
Copy
n = int(input())gomi = []for i in range(n):qn, r = map(int,input().split())gomi.append([qn, r])q = int (input())for i in range(q):t, d = map(int,input().split())rr = d % gomi[t - 1][0]if rr == gomi[t - 1][1]:print(d)elif rr < gomi[t - 1][1]:print(d + gomi[t - 1][1] - rr )else:print((d // gomi[t - 1][0] + 1) * gomi[t - 1][0] + gomi[t - 1][1])
n = int(input()) gomi = [] for i in range(n): qn, r = map(int,input().split()) gomi.append([qn, r]) q = int (input()) for i in range(q): t, d = map(int,input().split()) rr = d % gomi[t - 1][0] if rr == gomi[t - 1][1]: print(d) elif rr < gomi[t - 1][1]: print(d + gomi[t - 1][1] - rr ) else: print((d // gomi[t - 1][0] + 1) * gomi[t - 1][0] + gomi[t - 1][1])
Submission Info
Submission Time | |
---|---|
Task | B - Garbage Collection |
User | joshua123 |
Language | Python (CPython 3.11.4) |
Score | 200 |
Code Size | 426 Byte |
Status | AC |
Exec Time | 9 ms |
Memory | 8600 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 200 / 200 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | 00_sample_01.txt |
All | 00_sample_01.txt, 01_test_01.txt, 01_test_02.txt, 01_test_03.txt, 01_test_04.txt, 01_test_05.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
00_sample_01.txt | AC | 8 ms | 8600 KB |
01_test_01.txt | AC | 9 ms | 8532 KB |
01_test_02.txt | AC | 9 ms | 8564 KB |
01_test_03.txt | AC | 9 ms | 8448 KB |
01_test_04.txt | AC | 9 ms | 8428 KB |
01_test_05.txt | AC | 9 ms | 8520 KB |