Submission #72719183


Source Code Expand

n, q = map(int,input().split())
a = [0] + list(map(int,input().split()))
b = [0] * (n+1)
b[1] = a[1]

for i in range(1,n+1):
    if i == 1:
        continue
    b[i] = b[i-1] + a[i] 

#print(a,b)
for i in range(q):
    #print(b)
    j = tuple(map(int,input().split()))
    if j[0] == 1:
        ax1 = a[j[1]]
        ax2 = a[j[1]+1]
        a[j[1]] = ax2
        a[j[1]+1] = ax1
        b[j[1]] += ax2 - ax1

    if j[0] == 2:
        print(b[j[2]] - b[j[1]-1])

Submission Info

Submission Time
Task D - Swap and Range Sum
User hayahaya11
Language Python (PyPy 3.11-v7.3.20)
Score 400
Code Size 485 Byte
Status AC
Exec Time 1141 ms
Memory 142060 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 2
AC × 29
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, 01_random_20.txt, 01_random_21.txt, 01_random_22.txt, 01_random_23.txt, 02_handmade_00.txt, 02_handmade_01.txt, 02_handmade_02.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 52 ms 79428 KiB
00_sample_01.txt AC 51 ms 79412 KiB
01_random_00.txt AC 1103 ms 140948 KiB
01_random_01.txt AC 1076 ms 140564 KiB
01_random_02.txt AC 983 ms 140732 KiB
01_random_03.txt AC 870 ms 141176 KiB
01_random_04.txt AC 911 ms 141244 KiB
01_random_05.txt AC 831 ms 141096 KiB
01_random_06.txt AC 770 ms 141296 KiB
01_random_07.txt AC 733 ms 141464 KiB
01_random_08.txt AC 655 ms 141128 KiB
01_random_09.txt AC 617 ms 141444 KiB
01_random_10.txt AC 528 ms 141744 KiB
01_random_11.txt AC 1098 ms 141136 KiB
01_random_12.txt AC 1056 ms 141016 KiB
01_random_13.txt AC 970 ms 140804 KiB
01_random_14.txt AC 934 ms 141124 KiB
01_random_15.txt AC 919 ms 140888 KiB
01_random_16.txt AC 857 ms 141228 KiB
01_random_17.txt AC 802 ms 141396 KiB
01_random_18.txt AC 760 ms 142060 KiB
01_random_19.txt AC 715 ms 141528 KiB
01_random_20.txt AC 603 ms 141548 KiB
01_random_21.txt AC 524 ms 141400 KiB
01_random_22.txt AC 848 ms 141188 KiB
01_random_23.txt AC 843 ms 141524 KiB
02_handmade_00.txt AC 52 ms 79380 KiB
02_handmade_01.txt AC 51 ms 79736 KiB
02_handmade_02.txt AC 1141 ms 141744 KiB