結果

問題 No.1470 Mex Sum
ユーザー gorugo30
提出日時 2021-05-08 17:05:59
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 225 bytes
コンパイル時間 482 ms
コンパイル使用メモリ 82,328 KB
実行使用メモリ 100,228 KB
最終ジャッジ日時 2024-09-16 22:30:34
合計ジャッジ時間 7,400 ms
ジャッジサーバーID
(参考情報)
judge6 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 14 WA * 35
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
A = list(map(int, input().split()))
cnt1 = A.count(1)
cnt2 = A.count(2)
M = N * (N - 1) // 2
ans = 3 * cnt1 * cnt2
M -= cnt1 * cnt2
ans += 2 * cnt1 * (cnt1 - 1) // 2
M -= cnt1 * (cnt1 - 1) // 2
print(ans + M)
0