結果

問題 No.1470 Mex Sum
ユーザー vwxyzvwxyz
提出日時 2022-04-19 03:53:18
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 103 ms / 2,000 ms
コード長 478 bytes
コンパイル時間 334 ms
コンパイル使用メモリ 10,860 KB
実行使用メモリ 15,952 KB
最終ジャッジ日時 2023-08-29 05:42:25
合計ジャッジ時間 8,581 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
7,784 KB
testcase_01 AC 17 ms
7,860 KB
testcase_02 AC 24 ms
8,820 KB
testcase_03 AC 24 ms
8,944 KB
testcase_04 AC 24 ms
9,056 KB
testcase_05 AC 24 ms
9,108 KB
testcase_06 AC 25 ms
9,052 KB
testcase_07 AC 25 ms
9,088 KB
testcase_08 AC 25 ms
9,056 KB
testcase_09 AC 25 ms
9,048 KB
testcase_10 AC 24 ms
8,920 KB
testcase_11 AC 24 ms
9,048 KB
testcase_12 AC 101 ms
15,460 KB
testcase_13 AC 100 ms
15,368 KB
testcase_14 AC 99 ms
15,396 KB
testcase_15 AC 100 ms
15,580 KB
testcase_16 AC 98 ms
15,368 KB
testcase_17 AC 99 ms
15,444 KB
testcase_18 AC 97 ms
15,424 KB
testcase_19 AC 99 ms
15,432 KB
testcase_20 AC 99 ms
15,468 KB
testcase_21 AC 100 ms
15,616 KB
testcase_22 AC 102 ms
15,924 KB
testcase_23 AC 102 ms
15,848 KB
testcase_24 AC 102 ms
15,836 KB
testcase_25 AC 101 ms
15,852 KB
testcase_26 AC 103 ms
15,848 KB
testcase_27 AC 101 ms
15,776 KB
testcase_28 AC 101 ms
15,820 KB
testcase_29 AC 102 ms
15,788 KB
testcase_30 AC 101 ms
15,832 KB
testcase_31 AC 101 ms
15,776 KB
testcase_32 AC 101 ms
15,892 KB
testcase_33 AC 101 ms
15,952 KB
testcase_34 AC 102 ms
15,820 KB
testcase_35 AC 102 ms
15,868 KB
testcase_36 AC 101 ms
15,868 KB
testcase_37 AC 89 ms
11,332 KB
testcase_38 AC 90 ms
11,432 KB
testcase_39 AC 89 ms
11,316 KB
testcase_40 AC 90 ms
11,332 KB
testcase_41 AC 91 ms
11,316 KB
testcase_42 AC 89 ms
11,388 KB
testcase_43 AC 90 ms
11,384 KB
testcase_44 AC 90 ms
11,316 KB
testcase_45 AC 91 ms
11,320 KB
testcase_46 AC 91 ms
11,388 KB
testcase_47 AC 88 ms
11,312 KB
testcase_48 AC 90 ms
11,352 KB
testcase_49 AC 88 ms
11,388 KB
testcase_50 AC 92 ms
11,352 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
readline=sys.stdin.readline

N=int(readline())
A=list(map(int,readline().split()))
for i in range(N):
    if A[i]>=4:
        A[i]=3
cnt=[0]*4
for a in A:
    cnt[a]+=1
ans=0
for j in range(1,4):
    for i in range(1,j):
        for mex in range(1,4):
            if not mex in (i,j):
                break
        ans+=cnt[i]*cnt[j]*mex
for i in range(1,4):
    for mex in range(1,3):
        if mex!=i:
            break
    ans+=cnt[i]*(cnt[i]-1)//2*mex
print(ans)
0