Submission #12754173


Source Code Expand

Copy
import sys
from collections import defaultdict

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, *A = map(int, read().split())

memo = defaultdict(int)
answer = 0
for i, x in enumerate(A, 1):
    answer += memo[i - x]
    memo[x + i] += 1

print(answer)

Submission Info

Submission Time
Task E - This Message Will Self-Destruct in 5s
User maspy
Language Python (3.8.2)
Score 500
Code Size 328 Byte
Status
Exec Time 230 ms
Memory 61572 KB

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 sample_01.txt, sample_02.txt, sample_03.txt
Subtask1 500 / 500 sample_01.txt, sample_02.txt, sample_03.txt, sub1_01.txt, sub1_02.txt, sub1_03.txt, sub1_04.txt, sub1_05.txt, sub1_06.txt, sub1_07.txt, sub1_08.txt, sub1_09.txt, sub1_10.txt, sub1_11.txt, sub1_12.txt, sub1_13.txt, sub1_14.txt, sub1_15.txt, sub1_16.txt, sub1_17.txt, sub1_18.txt, sub1_19.txt, sub1_20.txt, sub1_21.txt, sub1_22.txt, sub1_23.txt, sub1_24.txt, sub1_25.txt, sub1_26.txt, sub1_27.txt, sub1_28.txt, sub1_29.txt, sub1_small_01.txt, sub1_small_02.txt, sub1_small_03.txt, sub1_small_04.txt, sub1_small_05.txt, sub1_small_06.txt, sub1_small_07.txt, sub1_small_08.txt, sub1_small_09.txt, sub1_small_10.txt, sub1_small_11.txt, sub1_small_12.txt, sub1_small_13.txt, sub1_small_14.txt, sub1_small_15.txt, sub1_small_16.txt, sub1_small_17.txt, sub1_small_18.txt, sub1_small_19.txt, sub1_small_20.txt
Case Name Status Exec Time Memory
sample_01.txt 21 ms 9176 KB
sample_02.txt 19 ms 9324 KB
sample_03.txt 26 ms 9328 KB
sub1_01.txt 119 ms 25160 KB
sub1_02.txt 91 ms 23752 KB
sub1_03.txt 197 ms 40464 KB
sub1_04.txt 230 ms 61572 KB
sub1_05.txt 62 ms 15948 KB
sub1_06.txt 158 ms 37516 KB
sub1_07.txt 55 ms 15344 KB
sub1_08.txt 142 ms 34368 KB
sub1_09.txt 99 ms 25568 KB
sub1_10.txt 147 ms 40760 KB
sub1_11.txt 103 ms 25064 KB
sub1_12.txt 178 ms 40396 KB
sub1_13.txt 55 ms 16980 KB
sub1_14.txt 167 ms 40756 KB
sub1_15.txt 36 ms 11944 KB
sub1_16.txt 46 ms 14028 KB
sub1_17.txt 194 ms 40472 KB
sub1_18.txt 102 ms 25592 KB
sub1_19.txt 136 ms 26600 KB
sub1_20.txt 165 ms 30352 KB
sub1_21.txt 55 ms 16808 KB
sub1_22.txt 141 ms 28472 KB
sub1_23.txt 164 ms 29840 KB
sub1_24.txt 151 ms 28828 KB
sub1_25.txt 162 ms 28552 KB
sub1_26.txt 160 ms 28448 KB
sub1_27.txt 76 ms 18480 KB
sub1_28.txt 86 ms 18064 KB
sub1_29.txt 162 ms 28244 KB
sub1_small_01.txt 19 ms 9456 KB
sub1_small_02.txt 19 ms 9144 KB
sub1_small_03.txt 22 ms 9164 KB
sub1_small_04.txt 24 ms 9404 KB
sub1_small_05.txt 20 ms 9520 KB
sub1_small_06.txt 23 ms 9524 KB
sub1_small_07.txt 20 ms 9344 KB
sub1_small_08.txt 21 ms 9572 KB
sub1_small_09.txt 22 ms 9308 KB
sub1_small_10.txt 20 ms 9340 KB
sub1_small_11.txt 22 ms 9728 KB
sub1_small_12.txt 19 ms 9184 KB
sub1_small_13.txt 21 ms 9604 KB
sub1_small_14.txt 21 ms 9280 KB
sub1_small_15.txt 20 ms 9428 KB
sub1_small_16.txt 23 ms 9664 KB
sub1_small_17.txt 25 ms 9524 KB
sub1_small_18.txt 23 ms 9520 KB
sub1_small_19.txt 22 ms 9668 KB
sub1_small_20.txt 20 ms 9524 KB