Submission #68182645


Source Code Expand

N = int(input())
A = list(map(int, input().split()))

# j-i = A[i] + A[j]
# <=>
# j - A[j] = i + A[i]

from collections import defaultdict
subCnt = defaultdict(int)
addCnt = defaultdict(int)

for i in range(N):
    subCnt[i - A[i]] += 1
    addCnt[i + A[i]] += 1

ans = 0
for key in subCnt:
    ans += subCnt[key] * addCnt[key]

print(ans)

Submission Info

Submission Time
Task C - Distance Indicators
User catupper
Language Python (PyPy 3.10-v7.3.12)
Score 300
Code Size 360 Byte
Status AC
Exec Time 182 ms
Memory 160092 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 3
AC × 29
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_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, 01_random_24.txt, 01_random_25.txt, 01_random_26.txt, 01_random_27.txt, 01_random_28.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 67 ms 76724 KiB
00_sample_01.txt AC 71 ms 76672 KiB
00_sample_02.txt AC 66 ms 77032 KiB
01_random_03.txt AC 144 ms 127416 KiB
01_random_04.txt AC 150 ms 136232 KiB
01_random_05.txt AC 118 ms 115072 KiB
01_random_06.txt AC 153 ms 138240 KiB
01_random_07.txt AC 178 ms 152344 KiB
01_random_08.txt AC 170 ms 152192 KiB
01_random_09.txt AC 182 ms 152220 KiB
01_random_10.txt AC 181 ms 152076 KiB
01_random_11.txt AC 123 ms 123972 KiB
01_random_12.txt AC 87 ms 91284 KiB
01_random_13.txt AC 124 ms 123924 KiB
01_random_14.txt AC 89 ms 89072 KiB
01_random_15.txt AC 129 ms 130500 KiB
01_random_16.txt AC 126 ms 116304 KiB
01_random_17.txt AC 105 ms 103792 KiB
01_random_18.txt AC 79 ms 83916 KiB
01_random_19.txt AC 115 ms 107944 KiB
01_random_20.txt AC 139 ms 120952 KiB
01_random_21.txt AC 140 ms 119968 KiB
01_random_22.txt AC 134 ms 120988 KiB
01_random_23.txt AC 132 ms 120936 KiB
01_random_24.txt AC 139 ms 160092 KiB
01_random_25.txt AC 134 ms 129292 KiB
01_random_26.txt AC 133 ms 129356 KiB
01_random_27.txt AC 131 ms 129964 KiB
01_random_28.txt AC 139 ms 129368 KiB