結果

問題 No.1470 Mex Sum
ユーザー ygd.ygd.
提出日時 2021-04-09 21:47:34
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 156 ms / 2,000 ms
コード長 319 bytes
コンパイル時間 888 ms
コンパイル使用メモリ 87,096 KB
実行使用メモリ 112,064 KB
最終ジャッジ日時 2023-09-07 10:43:49
合計ジャッジ時間 10,217 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 91 ms
71,620 KB
testcase_01 AC 91 ms
71,228 KB
testcase_02 AC 125 ms
78,448 KB
testcase_03 AC 103 ms
78,328 KB
testcase_04 AC 104 ms
78,624 KB
testcase_05 AC 103 ms
78,304 KB
testcase_06 AC 103 ms
78,604 KB
testcase_07 AC 106 ms
78,284 KB
testcase_08 AC 106 ms
78,628 KB
testcase_09 AC 103 ms
78,680 KB
testcase_10 AC 102 ms
78,580 KB
testcase_11 AC 102 ms
78,296 KB
testcase_12 AC 147 ms
111,336 KB
testcase_13 AC 148 ms
111,048 KB
testcase_14 AC 149 ms
111,040 KB
testcase_15 AC 146 ms
111,120 KB
testcase_16 AC 146 ms
111,040 KB
testcase_17 AC 148 ms
110,920 KB
testcase_18 AC 145 ms
110,908 KB
testcase_19 AC 152 ms
111,032 KB
testcase_20 AC 145 ms
111,020 KB
testcase_21 AC 145 ms
111,104 KB
testcase_22 AC 146 ms
112,064 KB
testcase_23 AC 153 ms
111,852 KB
testcase_24 AC 149 ms
111,392 KB
testcase_25 AC 153 ms
111,880 KB
testcase_26 AC 153 ms
111,168 KB
testcase_27 AC 151 ms
111,172 KB
testcase_28 AC 152 ms
111,888 KB
testcase_29 AC 156 ms
111,240 KB
testcase_30 AC 151 ms
111,244 KB
testcase_31 AC 152 ms
111,436 KB
testcase_32 AC 152 ms
111,968 KB
testcase_33 AC 152 ms
111,932 KB
testcase_34 AC 148 ms
111,900 KB
testcase_35 AC 150 ms
111,088 KB
testcase_36 AC 152 ms
111,856 KB
testcase_37 AC 134 ms
105,496 KB
testcase_38 AC 136 ms
105,808 KB
testcase_39 AC 135 ms
105,432 KB
testcase_40 AC 136 ms
105,500 KB
testcase_41 AC 135 ms
105,508 KB
testcase_42 AC 135 ms
105,508 KB
testcase_43 AC 136 ms
105,584 KB
testcase_44 AC 136 ms
105,708 KB
testcase_45 AC 137 ms
105,544 KB
testcase_46 AC 135 ms
105,568 KB
testcase_47 AC 134 ms
105,492 KB
testcase_48 AC 133 ms
105,528 KB
testcase_49 AC 136 ms
105,540 KB
testcase_50 AC 136 ms
105,680 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict

N = int(input())
A = list(map(int,input().split()))
dic = defaultdict(int)
for x in A:
    dic[x] += 1

ans = N*(N-1)//2 #すべて1

ones = dic[1]*(dic[1]-1)//2
ans += ones

onetwo = dic[1]*dic[2]
ans += onetwo * 2

oneelse = dic[1]*(N - dic[1] - dic[2])
ans += oneelse

print(ans)
0