Submission #69651885


Source Code Expand

from itertools import accumulate


N, Q = map(int, input().split())
A = list(map(int, input().split()))
cum = list(accumulate(A + A, initial=0))
d = 0

for _ in range(Q):
    query = list(map(int, input().split()))
    if query[0] == 1:
        d += query[1]
        d %= N
    else:
        l, r = query[1:]
        ans = cum[r + d] - cum[l + d - 1]
        print(ans)

Submission Info

Submission Time
Task C - Rotate and Sum Query
User mo12412
Language Python (PyPy 3.10-v7.3.12)
Score 350
Code Size 387 Byte
Status AC
Exec Time 466 ms
Memory 134692 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 350 / 350
Status
AC × 2
AC × 22
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt
All 00_sample_00.txt, 00_sample_01.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, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 01_random_15.txt, 01_random_16.txt, 01_random_17.txt, 01_random_18.txt, 01_random_19.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 57 ms 76456 KiB
00_sample_01.txt AC 57 ms 76420 KiB
01_random_00.txt AC 57 ms 76536 KiB
01_random_01.txt AC 290 ms 84516 KiB
01_random_02.txt AC 281 ms 121916 KiB
01_random_03.txt AC 158 ms 134672 KiB
01_random_04.txt AC 298 ms 85504 KiB
01_random_05.txt AC 346 ms 134692 KiB
01_random_06.txt AC 293 ms 84376 KiB
01_random_07.txt AC 342 ms 134436 KiB
01_random_08.txt AC 332 ms 121932 KiB
01_random_09.txt AC 340 ms 134384 KiB
01_random_10.txt AC 328 ms 117360 KiB
01_random_11.txt AC 339 ms 134348 KiB
01_random_12.txt AC 171 ms 134484 KiB
01_random_13.txt AC 172 ms 134368 KiB
01_random_14.txt AC 466 ms 134484 KiB
01_random_15.txt AC 466 ms 134428 KiB
01_random_16.txt AC 425 ms 134684 KiB
01_random_17.txt AC 260 ms 133960 KiB
01_random_18.txt AC 426 ms 131672 KiB
01_random_19.txt AC 321 ms 131320 KiB