結果

問題 No.3257 +|+
ユーザー chineristAC
提出日時 2025-09-05 23:17:55
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 348 ms / 3,000 ms
コード長 875 bytes
コンパイル時間 303 ms
コンパイル使用メモリ 82,536 KB
実行使用メモリ 161,800 KB
最終ジャッジ日時 2025-09-05 23:18:28
合計ジャッジ時間 10,113 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 33
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys,time

from itertools import permutations
from heapq import heappop,heappush
from collections import deque
import random
import bisect
from math import ceil,floor

input = lambda :sys.stdin.readline().rstrip()
mi = lambda :map(int,input().split())
li = lambda :list(mi())

M = 2*10**5

def solve(N,A):
    rest_idx = [i for i in range(N)]
    tmp_cnt = [0] * (2*M+1)
    ans = 0
    for q in range(1,2*M+1):
        nxt_idx = []
        for i in rest_idx:
            val = A[i] - q * (i+1)
            if -M <= val <= M:
                ans += tmp_cnt[M-val]
                tmp_cnt[val+M] += 1
                nxt_idx.append(i)
        for i in rest_idx:
            val = A[i] - q * (i+1)
            if -M <= val <= M:
                tmp_cnt[val+M] = 0
        rest_idx = nxt_idx
    
    return ans

N = int(input())
A = li()
print(solve(N,A))

            

0