結果

問題 No.1470 Mex Sum
ユーザー moharan627moharan627
提出日時 2021-04-09 21:40:30
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
実行時間 -
コード長 814 bytes
コンパイル時間 807 ms
コンパイル使用メモリ 10,812 KB
実行使用メモリ 15,964 KB
最終ジャッジ日時 2023-09-07 10:27:40
合計ジャッジ時間 17,493 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
8,308 KB
testcase_01 AC 18 ms
8,392 KB
testcase_02 AC 27 ms
8,784 KB
testcase_03 AC 26 ms
8,996 KB
testcase_04 AC 27 ms
9,028 KB
testcase_05 AC 27 ms
9,048 KB
testcase_06 AC 26 ms
9,044 KB
testcase_07 AC 26 ms
9,104 KB
testcase_08 AC 26 ms
9,028 KB
testcase_09 AC 26 ms
9,032 KB
testcase_10 AC 27 ms
8,984 KB
testcase_11 AC 26 ms
9,056 KB
testcase_12 AC 313 ms
15,388 KB
testcase_13 AC 307 ms
15,540 KB
testcase_14 AC 310 ms
15,316 KB
testcase_15 AC 316 ms
15,484 KB
testcase_16 AC 303 ms
15,396 KB
testcase_17 AC 302 ms
15,392 KB
testcase_18 AC 299 ms
15,240 KB
testcase_19 AC 306 ms
15,460 KB
testcase_20 AC 303 ms
15,260 KB
testcase_21 AC 318 ms
15,680 KB
testcase_22 AC 322 ms
15,964 KB
testcase_23 AC 318 ms
15,836 KB
testcase_24 AC 321 ms
15,912 KB
testcase_25 AC 321 ms
15,808 KB
testcase_26 AC 320 ms
15,928 KB
testcase_27 AC 320 ms
15,916 KB
testcase_28 AC 316 ms
15,732 KB
testcase_29 AC 319 ms
15,852 KB
testcase_30 AC 322 ms
15,852 KB
testcase_31 AC 319 ms
15,852 KB
testcase_32 AC 320 ms
15,788 KB
testcase_33 AC 319 ms
15,884 KB
testcase_34 AC 319 ms
15,844 KB
testcase_35 AC 322 ms
15,912 KB
testcase_36 AC 319 ms
15,684 KB
testcase_37 AC 1,308 ms
12,680 KB
testcase_38 RE -
testcase_39 RE -
testcase_40 AC 434 ms
11,576 KB
testcase_41 AC 432 ms
11,504 KB
testcase_42 AC 432 ms
11,392 KB
testcase_43 AC 432 ms
11,536 KB
testcase_44 AC 435 ms
11,504 KB
testcase_45 AC 432 ms
11,392 KB
testcase_46 AC 433 ms
11,476 KB
testcase_47 AC 436 ms
11,432 KB
testcase_48 AC 436 ms
11,552 KB
testcase_49 AC 433 ms
11,416 KB
testcase_50 AC 431 ms
11,412 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
sys.setrecursionlimit(10 ** 6)
def II(): return int(sys.stdin.readline())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LC(): return list(input())
def IC(): return [int(c) for c in input()]
def MI(): return map(int, sys.stdin.readline().split())
INF = float('inf')
MOD = 10**9 + 7
def solve():
    N = II()
    A = LI()
    One = 0
    Two = 0
    Other = 0
    for a in A:
        if(a==1):
            One+=1
        elif(a==2):
            Two+=1
        else:
            Other+=1
    import math
    def combinations_count(n, r):
        return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
    Thrid = One*Two
    Second = combinations_count(One, 2) + One*Other
    First = (N*(N-1))//2 - Thrid -Second
    print(3*Thrid+2*Second + First)
    return
solve()
0