結果

問題 No.1470 Mex Sum
ユーザー None
提出日時 2021-10-06 14:52:10
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 83 ms / 2,000 ms
コード長 253 bytes
コンパイル時間 181 ms
コンパイル使用メモリ 82,264 KB
実行使用メモリ 100,096 KB
最終ジャッジ日時 2024-07-23 02:53:10
合計ジャッジ時間 6,607 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 49
権限があれば一括ダウンロードができます

ソースコード

diff #

N=int(input())
A=list(map(int, input().split()))
cnt=[0]*4
for a in A:
    if a<=2:
        cnt[a]+=1
    else:
        cnt[3]+=1
res=0
res+=(cnt[2]+cnt[3])*(cnt[2]+cnt[3]-1)//2
res+=2*(cnt[1]*cnt[3]+cnt[1]*(cnt[1]-1)//2)
res+=3*cnt[1]*cnt[2]
print(res)
0