結果

問題 No.1470 Mex Sum
ユーザー NoaSaberNoaSaber
提出日時 2021-04-09 22:26:21
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 176 ms / 2,000 ms
コード長 546 bytes
コンパイル時間 481 ms
コンパイル使用メモリ 86,960 KB
実行使用メモリ 106,424 KB
最終ジャッジ日時 2023-09-07 11:54:19
合計ジャッジ時間 11,482 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 92 ms
71,436 KB
testcase_01 AC 91 ms
71,284 KB
testcase_02 AC 113 ms
77,900 KB
testcase_03 AC 112 ms
77,896 KB
testcase_04 AC 116 ms
78,276 KB
testcase_05 AC 111 ms
78,000 KB
testcase_06 AC 111 ms
78,344 KB
testcase_07 AC 112 ms
77,864 KB
testcase_08 AC 113 ms
78,344 KB
testcase_09 AC 111 ms
78,448 KB
testcase_10 AC 111 ms
78,280 KB
testcase_11 AC 116 ms
77,884 KB
testcase_12 AC 173 ms
106,076 KB
testcase_13 AC 172 ms
106,272 KB
testcase_14 AC 172 ms
106,324 KB
testcase_15 AC 173 ms
106,028 KB
testcase_16 AC 172 ms
106,052 KB
testcase_17 AC 175 ms
106,100 KB
testcase_18 AC 170 ms
105,948 KB
testcase_19 AC 171 ms
106,040 KB
testcase_20 AC 170 ms
106,128 KB
testcase_21 AC 172 ms
106,192 KB
testcase_22 AC 171 ms
106,172 KB
testcase_23 AC 174 ms
106,164 KB
testcase_24 AC 172 ms
106,132 KB
testcase_25 AC 172 ms
106,424 KB
testcase_26 AC 175 ms
106,368 KB
testcase_27 AC 173 ms
106,080 KB
testcase_28 AC 172 ms
106,156 KB
testcase_29 AC 173 ms
106,332 KB
testcase_30 AC 176 ms
105,748 KB
testcase_31 AC 170 ms
106,168 KB
testcase_32 AC 175 ms
106,012 KB
testcase_33 AC 174 ms
105,948 KB
testcase_34 AC 173 ms
105,964 KB
testcase_35 AC 174 ms
106,128 KB
testcase_36 AC 173 ms
105,804 KB
testcase_37 AC 161 ms
105,752 KB
testcase_38 AC 160 ms
105,776 KB
testcase_39 AC 159 ms
105,900 KB
testcase_40 AC 168 ms
105,804 KB
testcase_41 AC 168 ms
105,900 KB
testcase_42 AC 166 ms
105,736 KB
testcase_43 AC 166 ms
105,652 KB
testcase_44 AC 165 ms
105,768 KB
testcase_45 AC 166 ms
105,780 KB
testcase_46 AC 163 ms
105,616 KB
testcase_47 AC 167 ms
105,948 KB
testcase_48 AC 169 ms
105,764 KB
testcase_49 AC 168 ms
105,800 KB
testcase_50 AC 165 ms
105,780 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N=int(input())
A=list(map(int,input().split()))
from collections import Counter
one,two=0,0
other=0
l=[[0]*3 for i in range(N+1)]
for i in range(N):
    l[i+1][0]=l[i][0]
    l[i+1][2]=l[i][2]
    l[i+1][1]=l[i][1]
    if A[i]==1:
        l[i+1][0]+=1
    elif A[i]==2:
        l[i+1][1]+=1
    else:
        l[i+1][2]+=1
ans=0
for i,j in enumerate(A):
    tmp_l=l[i]
    if j==1:
        ans+=tmp_l[0]*2+tmp_l[1]*3+tmp_l[2]*2
    elif j==2:
        ans+=tmp_l[0]*3+tmp_l[1]+tmp_l[2]
    else:
        ans+=tmp_l[0]*2+tmp_l[1]+tmp_l[2]
print(ans)
0