結果

問題 No.2374 ASKT Subsequences
ユーザー flygonflygon
提出日時 2023-07-07 22:09:27
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 223 ms / 2,000 ms
コード長 732 bytes
コンパイル時間 290 ms
コンパイル使用メモリ 87,128 KB
実行使用メモリ 99,344 KB
最終ジャッジ日時 2023-09-28 23:28:03
合計ジャッジ時間 5,976 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 110 ms
77,600 KB
testcase_01 AC 109 ms
77,676 KB
testcase_02 AC 109 ms
77,700 KB
testcase_03 AC 111 ms
77,528 KB
testcase_04 AC 107 ms
77,736 KB
testcase_05 AC 105 ms
77,664 KB
testcase_06 AC 108 ms
77,504 KB
testcase_07 AC 109 ms
77,536 KB
testcase_08 AC 106 ms
77,696 KB
testcase_09 AC 109 ms
77,692 KB
testcase_10 AC 117 ms
78,180 KB
testcase_11 AC 123 ms
78,268 KB
testcase_12 AC 117 ms
78,120 KB
testcase_13 AC 116 ms
78,184 KB
testcase_14 AC 130 ms
78,380 KB
testcase_15 AC 128 ms
78,040 KB
testcase_16 AC 121 ms
77,904 KB
testcase_17 AC 134 ms
78,016 KB
testcase_18 AC 162 ms
93,644 KB
testcase_19 AC 157 ms
92,068 KB
testcase_20 AC 186 ms
99,244 KB
testcase_21 AC 191 ms
99,344 KB
testcase_22 AC 171 ms
97,004 KB
testcase_23 AC 158 ms
93,592 KB
testcase_24 AC 160 ms
93,328 KB
testcase_25 AC 132 ms
77,924 KB
testcase_26 AC 223 ms
99,204 KB
testcase_27 AC 179 ms
99,136 KB
testcase_28 AC 195 ms
98,940 KB
testcase_29 AC 170 ms
98,884 KB
testcase_30 AC 192 ms
98,964 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
sys.setrecursionlimit(5*10**5)
input = sys.stdin.readline
from collections import defaultdict, deque, Counter
from heapq import heappop, heappush
from bisect import bisect_left, bisect_right
from math import gcd

n = int(input())
a = list(map(int,input().split()))

cnt = [[0]*(n) for i in range(2010)]
for i in range(n):
    cnt[a[i]][i] = 1


for i in range(2010):
    for j in range(1,n):
        cnt[i][j] += cnt[i][j-1]
ans = 0
for a2 in range(1, n):
    for a3 in range(a2+1, n-1):
        k = a[a2] - a[a3]
        if k <= 0: continue
        a1 = a[a3] - 10 
        a4 = a[a2] + 1
        if not(1<= a1 <= 2000 and 1<= a4 <= 2000): continue
        ans += cnt[a1][a2-1] * (cnt[a4][-1] - cnt[a4][a3])

print(ans)
0