結果

問題 No.1470 Mex Sum
コンテスト
ユーザー otsuneko
提出日時 2021-05-04 02:12:02
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 67 ms / 2,000 ms
コード長 291 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 174 ms
コンパイル使用メモリ 84,904 KB
実行使用メモリ 97,920 KB
最終ジャッジ日時 2026-04-03 09:57:59
合計ジャッジ時間 4,257 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 49
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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

cnt_1 = A.count(1)
cnt_2 = A.count(2)
cnt_other = len(A)-cnt_1-cnt_2

ans = 0

ans += cnt_1*(cnt_1-1)//2 * 2
ans += cnt_1 * cnt_2 * 3
ans += cnt_1 * cnt_other * 2
ans += (cnt_2+cnt_other)*(cnt_2+cnt_other-1)//2

print(ans)
0