結果

問題 No.2374 ASKT Subsequences
ユーザー NP
提出日時 2023-07-07 22:21:59
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 798 bytes
コンパイル時間 270 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 80,512 KB
最終ジャッジ日時 2024-07-21 18:29:04
合計ジャッジ時間 5,770 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22 TLE * 1 -- * 5
権限があれば一括ダウンロードができます

ソースコード

diff #

import pypyjit
pypyjit.set_param('max_unroll_recursion=-1')
def count_asakatsu_subsequences(N, A):
    cnt = 0
    indices = {}
    for i, a in enumerate(A):
        if a not in indices:
            indices[a] = []
        indices[a].append(i)
    for i in range(N - 3):
        for j in range(i + 1, N - 2):
            k = A[j] - A[i] - 10
            if k > 0:
                m_values = indices.get(A[j] - k, [])
                for m in m_values:
                    if m > j:
                        n_values = indices.get(A[m] + k + 1, [])
                        for n in n_values:
                            if n > m:
                                cnt += 1
    return cnt

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


result = count_asakatsu_subsequences(N, A)


print(result)
0