結果
| 問題 | No.3456 Common Difference is D |
| コンテスト | |
| ユーザー |
hikikomori
|
| 提出日時 | 2026-02-19 14:11:54 |
| 言語 | PyPy3 (8.0.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 88 ms / 2,000 ms |
| + 855µs | |
| コード長 | 585 bytes |
| 記録 | |
| コンパイル時間 | 90 ms |
| コンパイル使用メモリ | 64,424 KB |
| 実行使用メモリ | 87,056 KB |
| 最終ジャッジ日時 | 2026-11-02 02:07:36 |
| 合計ジャッジ時間 | 3,278 ms |
|
ジャッジサーバーID (参考情報) |
judge4_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 22 |
ソースコード
from sys import stdin
input = stdin.readline
import collections
def solve():
N, D = map(int, input().split())
A = list(map(int, input().split()))
right_cnt = collections.Counter(A)
left_cnt= collections.Counter()
ans = 0
for x in A:
right_cnt[x] -= 1
val_i = x - D
val_k = x + D
count_i = left_cnt[val_i]
count_k = right_cnt[val_k]
if count_i > 0 and count_k > 0:
ans += count_i * count_k
left_cnt[x] += 1
print(ans)
if __name__ == "__main__":
solve()
hikikomori