結果

問題 No.1470 Mex Sum
ユーザー otsunekootsuneko
提出日時 2021-05-04 02:12:02
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 111 ms / 2,000 ms
コード長 291 bytes
コンパイル時間 365 ms
コンパイル使用メモリ 87,328 KB
実行使用メモリ 105,036 KB
最終ジャッジ日時 2023-09-29 22:11:58
合計ジャッジ時間 8,069 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,336 KB
testcase_01 AC 70 ms
71,304 KB
testcase_02 AC 76 ms
76,512 KB
testcase_03 AC 78 ms
76,212 KB
testcase_04 AC 77 ms
76,620 KB
testcase_05 AC 77 ms
76,472 KB
testcase_06 AC 77 ms
76,524 KB
testcase_07 AC 78 ms
76,396 KB
testcase_08 AC 78 ms
76,696 KB
testcase_09 AC 77 ms
76,544 KB
testcase_10 AC 77 ms
76,976 KB
testcase_11 AC 77 ms
76,212 KB
testcase_12 AC 110 ms
104,576 KB
testcase_13 AC 109 ms
104,616 KB
testcase_14 AC 110 ms
104,952 KB
testcase_15 AC 109 ms
104,624 KB
testcase_16 AC 109 ms
104,788 KB
testcase_17 AC 108 ms
104,604 KB
testcase_18 AC 107 ms
104,404 KB
testcase_19 AC 108 ms
104,504 KB
testcase_20 AC 109 ms
104,600 KB
testcase_21 AC 110 ms
104,660 KB
testcase_22 AC 109 ms
104,748 KB
testcase_23 AC 109 ms
104,764 KB
testcase_24 AC 110 ms
104,772 KB
testcase_25 AC 110 ms
104,624 KB
testcase_26 AC 109 ms
104,684 KB
testcase_27 AC 109 ms
104,808 KB
testcase_28 AC 111 ms
104,864 KB
testcase_29 AC 111 ms
104,920 KB
testcase_30 AC 110 ms
104,728 KB
testcase_31 AC 110 ms
104,848 KB
testcase_32 AC 111 ms
104,756 KB
testcase_33 AC 109 ms
105,036 KB
testcase_34 AC 110 ms
104,616 KB
testcase_35 AC 110 ms
104,696 KB
testcase_36 AC 109 ms
104,628 KB
testcase_37 AC 103 ms
103,828 KB
testcase_38 AC 104 ms
103,764 KB
testcase_39 AC 103 ms
103,724 KB
testcase_40 AC 106 ms
103,780 KB
testcase_41 AC 106 ms
103,804 KB
testcase_42 AC 107 ms
103,696 KB
testcase_43 AC 109 ms
103,928 KB
testcase_44 AC 107 ms
103,824 KB
testcase_45 AC 106 ms
103,784 KB
testcase_46 AC 107 ms
103,720 KB
testcase_47 AC 107 ms
103,804 KB
testcase_48 AC 107 ms
103,780 KB
testcase_49 AC 107 ms
103,668 KB
testcase_50 AC 107 ms
103,968 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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