Submission #68606670


Source Code Expand

Copy
#include <stdio.h>
#include <inttypes.h>
int N;
int A[212345];
int cnt[212345 * 2];
int main(void) {
int i;
uint64_t ans = 0;
if (scanf("%d", &N) != 1) return 1;
for (i = 1; i <= N; i++) {
int target;
if (scanf("%d", &A[i]) != 1) return 1;
target = i - A[i];
if (target >= 0) ans += cnt[target];
cnt[A[i] + i]++;
}
printf("%" PRIu64 "\n", ans);
return 0;
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#include <stdio.h>
#include <inttypes.h>

int N;
int A[212345];

int cnt[212345 * 2];

int main(void) {
	int i;
	uint64_t ans = 0;
	if (scanf("%d", &N) != 1) return 1;
	for (i = 1; i <= N; i++) {
		int target;
		if (scanf("%d", &A[i]) != 1) return 1;
		target = i - A[i];
		if (target >= 0) ans += cnt[target];
		cnt[A[i] + i]++;
	}
	printf("%" PRIu64 "\n", ans);
	return 0;
}

/*

j - i = A_i + A_j を変形すると A_i + i = j - A_j

*/

Submission Info

Submission Time
Task C - Distance Indicators
User mikecat
Language C (gcc 12.2.0)
Score 300
Code Size 469 Byte
Status AC
Exec Time 20 ms
Memory 4092 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 1 ms 1728 KiB
00_sample_01.txt AC 1 ms 1636 KiB
00_sample_02.txt AC 0 ms 1712 KiB
01_random_03.txt AC 11 ms 3276 KiB
01_random_04.txt AC 14 ms 3480 KiB
01_random_05.txt AC 8 ms 3064 KiB
01_random_06.txt AC 15 ms 3592 KiB
01_random_07.txt AC 20 ms 4088 KiB
01_random_08.txt AC 19 ms 4068 KiB
01_random_09.txt AC 20 ms 3968 KiB
01_random_10.txt AC 19 ms 4088 KiB
01_random_11.txt AC 12 ms 3404 KiB
01_random_12.txt AC 3 ms 1908 KiB
01_random_13.txt AC 10 ms 2564 KiB
01_random_14.txt AC 3 ms 1908 KiB
01_random_15.txt AC 12 ms 3292 KiB
01_random_16.txt AC 14 ms 3540 KiB
01_random_17.txt AC 8 ms 2760 KiB
01_random_18.txt AC 1 ms 1744 KiB
01_random_19.txt AC 11 ms 3120 KiB
01_random_20.txt AC 19 ms 4060 KiB
01_random_21.txt AC 17 ms 4068 KiB
01_random_22.txt AC 18 ms 4092 KiB
01_random_23.txt AC 16 ms 4008 KiB
01_random_24.txt AC 10 ms 3028 KiB
01_random_25.txt AC 12 ms 3300 KiB
01_random_26.txt AC 12 ms 3184 KiB
01_random_27.txt AC 12 ms 3220 KiB
01_random_28.txt AC 12 ms 3148 KiB


2025-08-18 (Mon)
07:35:11 +09:00