結果

問題 No.1470 Mex Sum
コンテスト
ユーザー aqua_tenhou
提出日時 2021-04-09 21:36:15
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 61 ms / 2,000 ms
コード長 381 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 358 ms
コンパイル使用メモリ 86,032 KB
実行使用メモリ 104,768 KB
最終ジャッジ日時 2026-03-11 09:25:34
合計ジャッジ時間 4,391 ms
ジャッジサーバーID
(参考情報)
judge3_1 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 49
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

n = int(input())
a = list(map(int,input().split()))

c = [0]*3
for x in a:
    if x <= 2:
        c[x] += 1

ans = 0
s = n
for x in a:
    s -= 1
    if x <= 2:
        c[x] -= 1
    if x == 1:
        ans += 2*(s-c[2])
        ans += 3*c[2]

    elif x == 2:
        ans += 1*(s-c[1])
        ans += 3*c[1]
    
    else:
        ans += 1*(s-c[1])
        ans += 2*c[1]
print(ans)
0