結果

問題 No.1470 Mex Sum
ユーザー shigeoku
提出日時 2021-04-09 22:22:51
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 115 ms / 2,000 ms
コード長 459 bytes
コンパイル時間 156 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 18,448 KB
最終ジャッジ日時 2024-06-25 05:58:31
合計ジャッジ時間 6,295 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 49
権限があれば一括ダウンロードができます

ソースコード

diff #

import collections


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

Bn = []
for A in An:
    if A > 2:
        Bn.append(3)
    else:
        Bn.append(A)
Bn_c = collections.Counter(Bn)

ans = 0
if Bn_c[1] >= 2:
    ans += Bn_c[1] * (Bn_c[1] - 1)
if Bn_c[2] >= 2:
    ans += Bn_c[2] * (Bn_c[2] - 1) // 2
if Bn_c[3] >= 2: 
    ans += Bn_c[3] * (Bn_c[3] - 1)  // 2
ans += (Bn_c[1]*Bn_c[2]*3)
ans += (Bn_c[1]*Bn_c[3]*2)
ans += Bn_c[2]*Bn_c[3]

print(ans)
0