Submission #21974272


Source Code Expand

import sys
from itertools import accumulate

input = sys.stdin.readline


def main():
    n = int(input())
    scores = [[0 for j in range(n)] for i in range(2)]
    for i in range(n):
        c, p = map(int, input().split())
        c -= 1
        scores[c][i] = p

    accums = [list(accumulate(s, initial=0)) for s in scores]
    q = int(input())
    for _ in range(q):
        l, r = map(int, input().split())
        l -= 1
        print(*(a[r] - a[l] for a in accums))


if __name__ == "__main__":
    main()

Submission Info

Submission Time
Task 010 - Score Sum Queries(★2)
User riantkb
Language Python (3.8.2)
Score 2
Code Size 515 Byte
Status AC
Exec Time 256 ms
Memory 18748 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 2 / 2
Status
AC × 4
AC × 18
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 27 ms 8900 KiB
hand02.txt AC 21 ms 8904 KiB
hand03.txt AC 252 ms 15420 KiB
hand04.txt AC 254 ms 15444 KiB
hand05.txt AC 249 ms 18748 KiB
hand06.txt AC 256 ms 12780 KiB
random01.txt AC 196 ms 13788 KiB
random02.txt AC 229 ms 14740 KiB
random03.txt AC 166 ms 11336 KiB
random04.txt AC 109 ms 10632 KiB
random05.txt AC 124 ms 11324 KiB
random06.txt AC 88 ms 10312 KiB
random07.txt AC 114 ms 10456 KiB
random08.txt AC 41 ms 9712 KiB
sample_01.txt AC 20 ms 9036 KiB
sample_02.txt AC 22 ms 9132 KiB
sample_03.txt AC 21 ms 9204 KiB
sample_04.txt AC 21 ms 9072 KiB