結果

問題 No.2374 ASKT Subsequences
ユーザー poyonpoyon
提出日時 2023-06-16 18:53:35
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 197 ms / 2,000 ms
コード長 740 bytes
コンパイル時間 278 ms
コンパイル使用メモリ 87,208 KB
実行使用メモリ 79,108 KB
最終ジャッジ日時 2023-09-12 09:54:21
合計ジャッジ時間 5,015 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,148 KB
testcase_01 AC 76 ms
75,008 KB
testcase_02 AC 73 ms
71,400 KB
testcase_03 AC 78 ms
75,008 KB
testcase_04 AC 83 ms
75,652 KB
testcase_05 AC 78 ms
75,280 KB
testcase_06 AC 78 ms
75,232 KB
testcase_07 AC 93 ms
76,876 KB
testcase_08 AC 96 ms
77,480 KB
testcase_09 AC 94 ms
77,384 KB
testcase_10 AC 103 ms
77,788 KB
testcase_11 AC 96 ms
77,356 KB
testcase_12 AC 93 ms
77,408 KB
testcase_13 AC 96 ms
77,488 KB
testcase_14 AC 101 ms
77,564 KB
testcase_15 AC 104 ms
77,452 KB
testcase_16 AC 99 ms
77,308 KB
testcase_17 AC 117 ms
77,652 KB
testcase_18 AC 124 ms
77,536 KB
testcase_19 AC 120 ms
77,448 KB
testcase_20 AC 173 ms
79,108 KB
testcase_21 AC 173 ms
78,908 KB
testcase_22 AC 159 ms
78,520 KB
testcase_23 AC 117 ms
77,164 KB
testcase_24 AC 121 ms
77,324 KB
testcase_25 AC 83 ms
75,868 KB
testcase_26 AC 197 ms
78,724 KB
testcase_27 AC 149 ms
78,116 KB
testcase_28 AC 88 ms
76,360 KB
testcase_29 AC 182 ms
78,572 KB
testcase_30 AC 125 ms
77,588 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