結果

問題 No.2374 ASKT Subsequences
ユーザー FromBooskaFromBooska
提出日時 2023-07-07 22:33:15
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,065 bytes
コンパイル時間 1,516 ms
コンパイル使用メモリ 87,124 KB
実行使用メモリ 110,152 KB
最終ジャッジ日時 2023-09-29 00:03:00
合計ジャッジ時間 5,623 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
76,012 KB
testcase_01 AC 77 ms
76,008 KB
testcase_02 AC 77 ms
75,956 KB
testcase_03 AC 76 ms
75,876 KB
testcase_04 AC 77 ms
76,072 KB
testcase_05 AC 77 ms
76,344 KB
testcase_06 AC 77 ms
75,840 KB
testcase_07 AC 78 ms
75,944 KB
testcase_08 AC 81 ms
75,980 KB
testcase_09 AC 79 ms
76,256 KB
testcase_10 AC 91 ms
78,588 KB
testcase_11 AC 105 ms
81,492 KB
testcase_12 WA -
testcase_13 AC 89 ms
78,548 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 127 ms
87,068 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 139 ms
92,752 KB
testcase_26 WA -
testcase_27 AC 203 ms
109,924 KB
testcase_28 WA -
testcase_29 AC 174 ms
109,696 KB
testcase_30 AC 203 ms
109,980 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