結果

問題 No.1470 Mex Sum
ユーザー 萩3萩3
提出日時 2021-05-03 00:10:45
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 117 ms / 2,000 ms
コード長 423 bytes
コンパイル時間 990 ms
コンパイル使用メモリ 86,692 KB
実行使用メモリ 97,548 KB
最終ジャッジ日時 2023-09-28 14:37:27
合計ジャッジ時間 11,125 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
71,084 KB
testcase_01 AC 73 ms
70,908 KB
testcase_02 AC 82 ms
75,872 KB
testcase_03 AC 82 ms
75,940 KB
testcase_04 AC 81 ms
76,124 KB
testcase_05 AC 81 ms
75,880 KB
testcase_06 AC 83 ms
75,900 KB
testcase_07 AC 83 ms
75,868 KB
testcase_08 AC 83 ms
75,896 KB
testcase_09 AC 83 ms
75,956 KB
testcase_10 AC 82 ms
75,880 KB
testcase_11 AC 85 ms
75,936 KB
testcase_12 AC 116 ms
97,140 KB
testcase_13 AC 114 ms
96,872 KB
testcase_14 AC 113 ms
96,856 KB
testcase_15 AC 117 ms
97,048 KB
testcase_16 AC 114 ms
96,720 KB
testcase_17 AC 115 ms
96,716 KB
testcase_18 AC 113 ms
96,792 KB
testcase_19 AC 115 ms
97,000 KB
testcase_20 AC 114 ms
96,932 KB
testcase_21 AC 117 ms
96,888 KB
testcase_22 AC 116 ms
97,528 KB
testcase_23 AC 117 ms
97,264 KB
testcase_24 AC 114 ms
97,272 KB
testcase_25 AC 114 ms
97,332 KB
testcase_26 AC 117 ms
97,272 KB
testcase_27 AC 114 ms
97,248 KB
testcase_28 AC 113 ms
97,372 KB
testcase_29 AC 117 ms
97,492 KB
testcase_30 AC 116 ms
97,432 KB
testcase_31 AC 116 ms
97,424 KB
testcase_32 AC 115 ms
97,512 KB
testcase_33 AC 114 ms
97,244 KB
testcase_34 AC 114 ms
97,284 KB
testcase_35 AC 117 ms
97,548 KB
testcase_36 AC 115 ms
97,480 KB
testcase_37 AC 97 ms
89,588 KB
testcase_38 AC 98 ms
89,312 KB
testcase_39 AC 98 ms
89,488 KB
testcase_40 AC 104 ms
89,580 KB
testcase_41 AC 103 ms
89,644 KB
testcase_42 AC 103 ms
89,732 KB
testcase_43 AC 104 ms
89,500 KB
testcase_44 AC 103 ms
89,288 KB
testcase_45 AC 102 ms
89,408 KB
testcase_46 AC 102 ms
89,796 KB
testcase_47 AC 102 ms
89,616 KB
testcase_48 AC 100 ms
89,500 KB
testcase_49 AC 103 ms
89,384 KB
testcase_50 AC 102 ms
89,648 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

def resolve():
    _ = input()
    cnt1,cnt2,cntother = 0,0,0
    for ai in map(int,sys.stdin.readline().split()):
        if ai == 1: cnt1 += 1
        elif ai == 2: cnt2 += 1
        else: cntother += 1

    result = 0
    if cnt1 > 1:
        result += cnt1*(cnt1-1)

    result += cnt1 * cnt2 * 3 + cnt1 * cntother * 2\
        + (cnt2 + cntother) * (cnt2 + cntother - 1) // 2

    print(result)

resolve()
0