結果

問題 No.1470 Mex Sum
ユーザー shigeokushigeoku
提出日時 2021-04-09 22:22:51
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 98 ms / 2,000 ms
コード長 459 bytes
コンパイル時間 337 ms
コンパイル使用メモリ 10,992 KB
実行使用メモリ 17,292 KB
最終ジャッジ日時 2023-09-07 11:49:39
合計ジャッジ時間 6,468 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 19 ms
8,560 KB
testcase_01 AC 18 ms
8,532 KB
testcase_02 AC 27 ms
9,216 KB
testcase_03 AC 27 ms
9,316 KB
testcase_04 AC 26 ms
9,328 KB
testcase_05 AC 26 ms
9,236 KB
testcase_06 AC 26 ms
9,244 KB
testcase_07 AC 26 ms
9,292 KB
testcase_08 AC 26 ms
9,440 KB
testcase_09 AC 26 ms
9,336 KB
testcase_10 AC 26 ms
9,396 KB
testcase_11 AC 26 ms
9,240 KB
testcase_12 AC 95 ms
15,816 KB
testcase_13 AC 91 ms
15,948 KB
testcase_14 AC 94 ms
16,368 KB
testcase_15 AC 95 ms
15,904 KB
testcase_16 AC 93 ms
15,976 KB
testcase_17 AC 93 ms
15,844 KB
testcase_18 AC 95 ms
16,156 KB
testcase_19 AC 95 ms
15,948 KB
testcase_20 AC 92 ms
16,352 KB
testcase_21 AC 96 ms
17,048 KB
testcase_22 AC 98 ms
15,924 KB
testcase_23 AC 97 ms
17,176 KB
testcase_24 AC 96 ms
15,944 KB
testcase_25 AC 96 ms
16,108 KB
testcase_26 AC 95 ms
15,952 KB
testcase_27 AC 96 ms
16,008 KB
testcase_28 AC 95 ms
17,264 KB
testcase_29 AC 96 ms
16,096 KB
testcase_30 AC 96 ms
16,020 KB
testcase_31 AC 96 ms
16,048 KB
testcase_32 AC 95 ms
16,056 KB
testcase_33 AC 96 ms
16,048 KB
testcase_34 AC 98 ms
17,172 KB
testcase_35 AC 96 ms
16,056 KB
testcase_36 AC 96 ms
17,292 KB
testcase_37 AC 87 ms
12,460 KB
testcase_38 AC 86 ms
12,572 KB
testcase_39 AC 83 ms
12,568 KB
testcase_40 AC 86 ms
12,588 KB
testcase_41 AC 88 ms
12,576 KB
testcase_42 AC 86 ms
12,600 KB
testcase_43 AC 88 ms
12,440 KB
testcase_44 AC 86 ms
12,468 KB
testcase_45 AC 88 ms
12,504 KB
testcase_46 AC 84 ms
12,508 KB
testcase_47 AC 85 ms
12,504 KB
testcase_48 AC 87 ms
12,572 KB
testcase_49 AC 87 ms
12,416 KB
testcase_50 AC 87 ms
12,508 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import collections


N = int(input())
An = list(map(int, input().split()))

Bn = []
for A in An:
    if A > 2:
        Bn.append(3)
    else:
        Bn.append(A)
Bn_c = collections.Counter(Bn)

ans = 0
if Bn_c[1] >= 2:
    ans += Bn_c[1] * (Bn_c[1] - 1)
if Bn_c[2] >= 2:
    ans += Bn_c[2] * (Bn_c[2] - 1) // 2
if Bn_c[3] >= 2: 
    ans += Bn_c[3] * (Bn_c[3] - 1)  // 2
ans += (Bn_c[1]*Bn_c[2]*3)
ans += (Bn_c[1]*Bn_c[3]*2)
ans += Bn_c[2]*Bn_c[3]

print(ans)
0