結果

問題 No.2374 ASKT Subsequences
ユーザー FromBooskaFromBooska
提出日時 2023-07-07 22:40:54
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 284 ms / 2,000 ms
コード長 1,066 bytes
コンパイル時間 1,401 ms
コンパイル使用メモリ 86,980 KB
実行使用メモリ 109,872 KB
最終ジャッジ日時 2023-09-29 00:14:42
合計ジャッジ時間 6,855 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
75,884 KB
testcase_01 AC 81 ms
75,952 KB
testcase_02 AC 78 ms
76,004 KB
testcase_03 AC 77 ms
75,884 KB
testcase_04 AC 78 ms
75,832 KB
testcase_05 AC 77 ms
75,904 KB
testcase_06 AC 78 ms
75,964 KB
testcase_07 AC 80 ms
75,880 KB
testcase_08 AC 79 ms
75,908 KB
testcase_09 AC 80 ms
75,952 KB
testcase_10 AC 97 ms
78,600 KB
testcase_11 AC 106 ms
81,288 KB
testcase_12 AC 92 ms
78,440 KB
testcase_13 AC 92 ms
78,460 KB
testcase_14 AC 113 ms
81,568 KB
testcase_15 AC 115 ms
84,188 KB
testcase_16 AC 109 ms
81,192 KB
testcase_17 AC 128 ms
86,888 KB
testcase_18 AC 154 ms
92,656 KB
testcase_19 AC 148 ms
90,192 KB
testcase_20 AC 202 ms
98,448 KB
testcase_21 AC 215 ms
101,308 KB
testcase_22 AC 176 ms
95,640 KB
testcase_23 AC 155 ms
92,676 KB
testcase_24 AC 156 ms
92,792 KB
testcase_25 AC 136 ms
92,784 KB
testcase_26 AC 284 ms
109,864 KB
testcase_27 AC 192 ms
109,872 KB
testcase_28 AC 206 ms
109,616 KB
testcase_29 AC 176 ms
109,676 KB
testcase_30 AC 204 ms
109,740 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# 二重ループ可能
# a2とa3を決めれば、k, a1, a4も決まる
# a2とa3を決めたときにa2までのa1の個数かけるa3後のa4の個数
# インデックス番号までにどの数字が何個出ていたかカウントする

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

A_max = 2001 # 2001にすること
count = []
old = [0]*A_max
count.append(old)
for i in range(N):
    new = []
    for j in range(A_max):
        new.append(old[j])
    new[A[i]] += 1
    count.append(new)
    old = new
    
ans = 0
for a2_idx in range(1, N-2):
    for a3_idx in range(a2_idx+1, N-1):
        #print('a2_idx', a2_idx, 'a3_idx', a3_idx)
        a2 = A[a2_idx]
        k = a2 - A[a3_idx]
        
        if k <= 0:
            continue
        a1 = a2-(k+10)
        a4 = a2+1
        if a1 <= 0 or A_max <= a1:
            continue
        if a4 <= 0 or A_max <= a4:
            continue        
        add = count[a2_idx][a1]*(count[N][a4]-count[a3_idx+1][a4])
        #print('a2', a2, 'k', k, 'add', add)
        ans += add
print(ans)
        


0