結果

問題 No.1470 Mex Sum
ユーザー lloyzlloyz
提出日時 2022-01-19 00:24:49
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 99 ms / 2,000 ms
コード長 339 bytes
コンパイル時間 107 ms
コンパイル使用メモリ 10,704 KB
実行使用メモリ 15,752 KB
最終ジャッジ日時 2023-08-15 07:46:56
合計ジャッジ時間 5,941 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,824 KB
testcase_01 AC 15 ms
7,892 KB
testcase_02 AC 24 ms
8,956 KB
testcase_03 AC 23 ms
8,904 KB
testcase_04 AC 23 ms
8,868 KB
testcase_05 AC 24 ms
8,856 KB
testcase_06 AC 23 ms
8,924 KB
testcase_07 AC 24 ms
8,960 KB
testcase_08 AC 23 ms
8,976 KB
testcase_09 AC 23 ms
8,992 KB
testcase_10 AC 23 ms
8,856 KB
testcase_11 AC 24 ms
8,916 KB
testcase_12 AC 93 ms
15,396 KB
testcase_13 AC 92 ms
15,512 KB
testcase_14 AC 96 ms
15,628 KB
testcase_15 AC 93 ms
15,552 KB
testcase_16 AC 94 ms
15,612 KB
testcase_17 AC 90 ms
15,448 KB
testcase_18 AC 94 ms
15,388 KB
testcase_19 AC 94 ms
15,396 KB
testcase_20 AC 93 ms
15,560 KB
testcase_21 AC 96 ms
15,692 KB
testcase_22 AC 98 ms
15,620 KB
testcase_23 AC 98 ms
15,688 KB
testcase_24 AC 96 ms
15,684 KB
testcase_25 AC 96 ms
15,712 KB
testcase_26 AC 97 ms
15,712 KB
testcase_27 AC 94 ms
15,588 KB
testcase_28 AC 98 ms
15,620 KB
testcase_29 AC 99 ms
15,720 KB
testcase_30 AC 99 ms
15,712 KB
testcase_31 AC 97 ms
15,752 KB
testcase_32 AC 97 ms
15,708 KB
testcase_33 AC 96 ms
15,636 KB
testcase_34 AC 97 ms
15,652 KB
testcase_35 AC 94 ms
15,696 KB
testcase_36 AC 95 ms
15,576 KB
testcase_37 AC 88 ms
11,284 KB
testcase_38 AC 88 ms
11,408 KB
testcase_39 AC 76 ms
11,332 KB
testcase_40 AC 90 ms
11,464 KB
testcase_41 AC 91 ms
11,292 KB
testcase_42 AC 87 ms
11,308 KB
testcase_43 AC 91 ms
11,416 KB
testcase_44 AC 89 ms
11,328 KB
testcase_45 AC 89 ms
11,360 KB
testcase_46 AC 91 ms
11,404 KB
testcase_47 AC 90 ms
11,260 KB
testcase_48 AC 91 ms
11,300 KB
testcase_49 AC 89 ms
11,472 KB
testcase_50 AC 89 ms
11,356 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

L = [0, 0, 0, 0]
for i in range(n):
    if A[i] <= 2:
        L[A[i]] += 1
    else:
        L[3] += 1

ans = 0
ans += L[1] * (L[1] - 1)
ans += L[2] * (L[2] - 1) // 2 + L[3] * (L[3] - 1) // 2
ans += 3 * L[1] * L[2]
ans += 2 * L[1] * L[3]
ans += L[2] * L[3]
print(ans)
0