結果

問題 No.1470 Mex Sum
ユーザー 👑 SPD_9X2SPD_9X2
提出日時 2021-04-09 21:29:04
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 120 ms / 2,000 ms
コード長 420 bytes
コンパイル時間 280 ms
コンパイル使用メモリ 87,172 KB
実行使用メモリ 104,712 KB
最終ジャッジ日時 2023-09-07 09:55:21
合計ジャッジ時間 7,923 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,228 KB
testcase_01 AC 73 ms
71,520 KB
testcase_02 AC 81 ms
77,000 KB
testcase_03 AC 80 ms
76,628 KB
testcase_04 AC 87 ms
77,296 KB
testcase_05 AC 81 ms
76,696 KB
testcase_06 AC 82 ms
76,996 KB
testcase_07 AC 80 ms
76,920 KB
testcase_08 AC 80 ms
77,276 KB
testcase_09 AC 80 ms
77,292 KB
testcase_10 AC 80 ms
77,168 KB
testcase_11 AC 79 ms
76,920 KB
testcase_12 AC 113 ms
104,672 KB
testcase_13 AC 115 ms
104,564 KB
testcase_14 AC 116 ms
104,564 KB
testcase_15 AC 113 ms
104,632 KB
testcase_16 AC 115 ms
104,332 KB
testcase_17 AC 116 ms
104,212 KB
testcase_18 AC 116 ms
104,484 KB
testcase_19 AC 114 ms
104,244 KB
testcase_20 AC 117 ms
104,516 KB
testcase_21 AC 117 ms
104,472 KB
testcase_22 AC 115 ms
104,676 KB
testcase_23 AC 120 ms
104,680 KB
testcase_24 AC 117 ms
104,620 KB
testcase_25 AC 117 ms
104,548 KB
testcase_26 AC 116 ms
104,688 KB
testcase_27 AC 116 ms
104,676 KB
testcase_28 AC 117 ms
104,500 KB
testcase_29 AC 115 ms
104,712 KB
testcase_30 AC 115 ms
104,672 KB
testcase_31 AC 116 ms
104,604 KB
testcase_32 AC 115 ms
104,676 KB
testcase_33 AC 117 ms
104,548 KB
testcase_34 AC 119 ms
104,648 KB
testcase_35 AC 116 ms
104,412 KB
testcase_36 AC 117 ms
104,668 KB
testcase_37 AC 110 ms
103,752 KB
testcase_38 AC 109 ms
103,756 KB
testcase_39 AC 110 ms
103,664 KB
testcase_40 AC 113 ms
103,792 KB
testcase_41 AC 117 ms
104,064 KB
testcase_42 AC 112 ms
104,004 KB
testcase_43 AC 111 ms
104,040 KB
testcase_44 AC 114 ms
103,720 KB
testcase_45 AC 113 ms
104,076 KB
testcase_46 AC 112 ms
103,952 KB
testcase_47 AC 113 ms
103,952 KB
testcase_48 AC 113 ms
103,948 KB
testcase_49 AC 111 ms
104,008 KB
testcase_50 AC 112 ms
103,788 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

"""


"""

import sys
from sys import stdin

N = int(stdin.readline())

A = list(map(int,stdin.readline().split()))

one = 0
two = 0
other = 0

for i in A:
    if i == 2:
        two += 1
    elif i == 1:
        one += 1
    else:
        other += 1

ans = 0
ans += 2 * (one * (one-1)//2)
ans += 2 * (one * other)
ans += 3 * (one * two)
ans += 1 * ( N*(N-1)//2 - one * (one-1)//2 - one * two - one * other)
print (ans)
0