結果

問題 No.2374 ASKT Subsequences
ユーザー poyonpoyon
提出日時 2023-06-16 19:19:57
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 879 ms / 2,000 ms
コード長 869 bytes
コンパイル時間 295 ms
コンパイル使用メモリ 87,016 KB
実行使用メモリ 143,192 KB
最終ジャッジ日時 2023-09-12 09:54:46
合計ジャッジ時間 10,199 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
75,252 KB
testcase_01 AC 80 ms
76,532 KB
testcase_02 AC 74 ms
71,372 KB
testcase_03 AC 83 ms
76,316 KB
testcase_04 AC 87 ms
76,216 KB
testcase_05 AC 83 ms
76,596 KB
testcase_06 AC 84 ms
76,516 KB
testcase_07 AC 122 ms
77,756 KB
testcase_08 AC 127 ms
78,260 KB
testcase_09 AC 124 ms
77,948 KB
testcase_10 AC 240 ms
85,084 KB
testcase_11 AC 133 ms
78,016 KB
testcase_12 AC 130 ms
77,888 KB
testcase_13 AC 130 ms
77,692 KB
testcase_14 AC 136 ms
77,900 KB
testcase_15 AC 138 ms
78,064 KB
testcase_16 AC 133 ms
77,992 KB
testcase_17 AC 257 ms
84,356 KB
testcase_18 AC 263 ms
84,004 KB
testcase_19 AC 262 ms
85,440 KB
testcase_20 AC 855 ms
142,752 KB
testcase_21 AC 863 ms
143,192 KB
testcase_22 AC 761 ms
131,976 KB
testcase_23 AC 265 ms
84,744 KB
testcase_24 AC 266 ms
85,064 KB
testcase_25 AC 85 ms
75,568 KB
testcase_26 AC 879 ms
136,344 KB
testcase_27 AC 757 ms
126,444 KB
testcase_28 AC 93 ms
76,448 KB
testcase_29 AC 794 ms
127,668 KB
testcase_30 AC 188 ms
79,628 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[x][j] := (A[0] 〜 A[i-1] まで見て、) x = a1 であって、
        #             あさかつ型の部分列の j 番目まで決めた場合の数
        # dp = [[0] * 4 for _ in range(MAX_A + 1)]
        dp = [[0 for i in range(4)] for j in range(MAX_A + 1)]  # kanten さんのやつ
        for a in A:
            x = a - k - 11
            if 1 <= x: dp[x][3] += dp[x][2]

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

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

            dp[a][0] += 1

        for x in range(1, MAX_A + 1):
            ans += dp[x][3]

    print(ans)


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