Submission #37674140
Source Code Expand
N = int(input())
from collections import defaultdict
ps = [[0] * (N+1) for _ in range(2)]
for i in range(1, N+1):
c, p = map(int, input().split())
c -= 1
for j in range(2):
ps[j][i] = ps[j][i-1]
if c == j:
ps[j][i] += p
Q = int(input())
for _ in range(Q):
l, r = map(int, input().split())
l -= 1
r -= 1
a = ps[0][r+1] - ps[0][l]
b = ps[1][r+1] - ps[1][l]
print(f"{a} {b}")
Submission Info
| Submission Time | |
|---|---|
| Task | 010 - Score Sum Queries(★2) |
| User | moshida |
| Language | PyPy3 (7.3.0) |
| Score | 2 |
| Code Size | 435 Byte |
| Status | AC |
| Exec Time | 503 ms |
| Memory | 79892 KiB |
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 2 / 2 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt |
| All | hand01.txt, hand02.txt, hand03.txt, hand04.txt, hand05.txt, hand06.txt, random01.txt, random02.txt, random03.txt, random04.txt, random05.txt, random06.txt, random07.txt, random08.txt, sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| hand01.txt | AC | 70 ms | 64844 KiB |
| hand02.txt | AC | 57 ms | 64744 KiB |
| hand03.txt | AC | 496 ms | 78392 KiB |
| hand04.txt | AC | 488 ms | 78168 KiB |
| hand05.txt | AC | 478 ms | 79892 KiB |
| hand06.txt | AC | 503 ms | 79712 KiB |
| random01.txt | AC | 382 ms | 77224 KiB |
| random02.txt | AC | 448 ms | 78272 KiB |
| random03.txt | AC | 350 ms | 77736 KiB |
| random04.txt | AC | 252 ms | 77560 KiB |
| random05.txt | AC | 288 ms | 78504 KiB |
| random06.txt | AC | 224 ms | 76536 KiB |
| random07.txt | AC | 270 ms | 76768 KiB |
| random08.txt | AC | 135 ms | 76660 KiB |
| sample_01.txt | AC | 55 ms | 64852 KiB |
| sample_02.txt | AC | 54 ms | 65180 KiB |
| sample_03.txt | AC | 56 ms | 64688 KiB |
| sample_04.txt | AC | 56 ms | 65180 KiB |