提出 #45048105


ソースコード 拡げる

n, k = map(int, input().split())
a = list(map(int, input().split()))
r = [None for _ in range(n)]
for i in range(n - 1):
    if i == 0:
        r[i] = 0
    else:
        r[i] = r[i - 1]
    while r[i] < n - 1 and a[r[i] + 1] - a[i] <= k:
            r[i] += 1
ans = 0
for i in range(n - 1):
    ans += (r[i] - i)
print(ans)

提出情報

提出日時
問題 A13 - Close Pairs
ユーザ harry_arbrebleu
言語 PyPy3 (7.3.0)
得点 1000
コード長 339 Byte
結果 AC
実行時間 99 ms
メモリ 91272 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 1000 / 1000
結果
AC × 1
AC × 21
セット名 テストケース
Sample sample_01.txt
All 10_random_small_00.txt, 10_random_small_01.txt, 10_random_small_02.txt, 10_random_small_03.txt, 10_random_small_04.txt, 10_random_small_05.txt, 10_random_small_06.txt, 10_random_small_07.txt, 10_random_small_08.txt, 10_random_small_09.txt, 20_random_large_00.txt, 20_random_large_01.txt, 20_random_large_02.txt, 20_random_large_03.txt, 20_random_large_04.txt, 20_random_large_05.txt, 20_random_large_06.txt, 20_random_large_07.txt, 20_random_large_08.txt, 20_random_large_09.txt, sample_01.txt
ケース名 結果 実行時間 メモリ
10_random_small_00.txt AC 62 ms 61912 KiB
10_random_small_01.txt AC 54 ms 61912 KiB
10_random_small_02.txt AC 51 ms 61816 KiB
10_random_small_03.txt AC 48 ms 61808 KiB
10_random_small_04.txt AC 50 ms 61584 KiB
10_random_small_05.txt AC 56 ms 61620 KiB
10_random_small_06.txt AC 47 ms 61800 KiB
10_random_small_07.txt AC 45 ms 61788 KiB
10_random_small_08.txt AC 50 ms 61608 KiB
10_random_small_09.txt AC 49 ms 61640 KiB
20_random_large_00.txt AC 90 ms 86632 KiB
20_random_large_01.txt AC 86 ms 84708 KiB
20_random_large_02.txt AC 84 ms 83196 KiB
20_random_large_03.txt AC 96 ms 90928 KiB
20_random_large_04.txt AC 93 ms 88592 KiB
20_random_large_05.txt AC 88 ms 86660 KiB
20_random_large_06.txt AC 99 ms 91272 KiB
20_random_large_07.txt AC 93 ms 88592 KiB
20_random_large_08.txt AC 97 ms 91164 KiB
20_random_large_09.txt AC 95 ms 90984 KiB
sample_01.txt AC 48 ms 61744 KiB