結果

問題 No.2374 ASKT Subsequences
ユーザー 21kazu1321kazu13
提出日時 2023-07-07 22:53:19
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,593 bytes
コンパイル時間 2,360 ms
コンパイル使用メモリ 86,968 KB
実行使用メモリ 145,332 KB
最終ジャッジ日時 2023-09-29 00:28:35
合計ジャッジ時間 9,917 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 169 ms
79,752 KB
testcase_01 AC 167 ms
79,956 KB
testcase_02 AC 170 ms
79,612 KB
testcase_03 AC 165 ms
79,572 KB
testcase_04 AC 164 ms
79,756 KB
testcase_05 AC 162 ms
79,764 KB
testcase_06 WA -
testcase_07 AC 167 ms
79,744 KB
testcase_08 AC 162 ms
79,496 KB
testcase_09 AC 162 ms
79,968 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 256 ms
113,628 KB
testcase_26 WA -
testcase_27 AC 334 ms
145,212 KB
testcase_28 WA -
testcase_29 AC 329 ms
145,332 KB
testcase_30 AC 341 ms
145,192 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python3
import sys
from bisect import bisect_left, bisect_right, insort_left, insort_right  # type: ignore
from collections import Counter, defaultdict, deque  # type: ignore
from math import gcd, sqrt, ceil  # type: ignore
from heapq import heapify, heappop, heappush, heappushpop, heapreplace, merge  # type: ignore
from itertools import accumulate, combinations, permutations, product  # type: ignore
from string import ascii_lowercase, ascii_uppercase # type: ignore

def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode("utf-8").split()
def S(): return sys.stdin.buffer.readline().rstrip().decode("utf-8")
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
def SRL(n): return [list(S()) for _ in range(n)]

N = I()
A = LI()
num = [[] for _ in range(2020)]
cnt = [[0]*(N+1) for _ in range(2020)]
for i,a in enumerate(A):
    num[a].append(i)
    for j in num[a-1]:
        cnt[a-1][j+1]+=1
        cnt[a-1][i]-=1

for i in range(2020):
    cnt[i] = list(accumulate(cnt[i]))
for i in range(2019,0,-1):
    for j in range(N+1):
        cnt[i-1][j] += cnt[i][j]

ans = 0
for i in range(N):
    a1 = A[i]
    for k in num[a1+10]:
        if k-i<2: continue
        a3 = A[k]
        # if cnt[a3+1][k]>0:
        #     print(i,k,a3+1,cnt[a3+1][k])
        #     print(cnt[a3+1])
        ans += cnt[a3+1][k]-cnt[a3+1][i]
print(ans)

0