結果

問題 No.2374 ASKT Subsequences
ユーザー poyonpoyon
提出日時 2023-06-20 22:08:00
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 199 ms / 2,000 ms
コード長 740 bytes
コンパイル時間 268 ms
コンパイル使用メモリ 87,268 KB
実行使用メモリ 78,928 KB
最終ジャッジ日時 2023-09-12 09:57:43
合計ジャッジ時間 4,962 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,296 KB
testcase_01 AC 74 ms
75,276 KB
testcase_02 AC 72 ms
71,448 KB
testcase_03 AC 75 ms
75,272 KB
testcase_04 AC 81 ms
75,568 KB
testcase_05 AC 73 ms
75,160 KB
testcase_06 AC 76 ms
75,140 KB
testcase_07 AC 89 ms
76,852 KB
testcase_08 AC 93 ms
77,428 KB
testcase_09 AC 94 ms
77,124 KB
testcase_10 AC 104 ms
77,736 KB
testcase_11 AC 95 ms
77,476 KB
testcase_12 AC 93 ms
77,340 KB
testcase_13 AC 94 ms
77,324 KB
testcase_14 AC 101 ms
77,408 KB
testcase_15 AC 105 ms
77,468 KB
testcase_16 AC 100 ms
77,356 KB
testcase_17 AC 116 ms
77,480 KB
testcase_18 AC 122 ms
77,536 KB
testcase_19 AC 118 ms
77,684 KB
testcase_20 AC 169 ms
78,928 KB
testcase_21 AC 173 ms
78,768 KB
testcase_22 AC 157 ms
78,392 KB
testcase_23 AC 122 ms
77,268 KB
testcase_24 AC 124 ms
77,504 KB
testcase_25 AC 83 ms
75,832 KB
testcase_26 AC 199 ms
78,800 KB
testcase_27 AC 151 ms
78,184 KB
testcase_28 AC 91 ms
76,396 KB
testcase_29 AC 184 ms
78,480 KB
testcase_30 AC 127 ms
77,656 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

input = sys.stdin.readline


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

    ans = 0
    MAX_A = max(A)
    for k in range(1, MAX_A + 1):
        # dp[j][x] := (A[0] 〜 A[i-1] まで見て、) x = a1 であって、
        #             あさかつ型の部分列の j 番目まで決めた場合の数
        dp = [[0] * (MAX_A + 1) for _ in range(4)]
        for a in A:
            x = a - k - 11
            if 1 <= x: dp[3][x] += dp[2][x]

            y = a - 10
            if 1 <= y: dp[2][y] += dp[1][y]

            z = a - k - 10
            if 1 <= z: dp[1][z] += dp[0][z]

            dp[0][a] += 1

        ans += sum(dp[3])

    print(ans)


if __name__ == "__main__":
    main()
0