結果

問題 No.1470 Mex Sum
ユーザー 8nd5t8nd5t
提出日時 2021-04-09 21:35:44
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 142 ms / 2,000 ms
コード長 752 bytes
コンパイル時間 1,007 ms
コンパイル使用メモリ 86,940 KB
実行使用メモリ 105,844 KB
最終ジャッジ日時 2023-09-07 10:13:51
合計ジャッジ時間 9,066 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 98 ms
71,736 KB
testcase_01 AC 92 ms
71,644 KB
testcase_02 AC 100 ms
77,820 KB
testcase_03 AC 101 ms
78,108 KB
testcase_04 AC 102 ms
78,288 KB
testcase_05 AC 102 ms
78,144 KB
testcase_06 AC 103 ms
78,344 KB
testcase_07 AC 99 ms
77,860 KB
testcase_08 AC 100 ms
78,368 KB
testcase_09 AC 102 ms
78,376 KB
testcase_10 AC 102 ms
78,216 KB
testcase_11 AC 105 ms
78,028 KB
testcase_12 AC 133 ms
105,632 KB
testcase_13 AC 133 ms
105,524 KB
testcase_14 AC 139 ms
105,624 KB
testcase_15 AC 133 ms
105,632 KB
testcase_16 AC 133 ms
105,712 KB
testcase_17 AC 136 ms
105,364 KB
testcase_18 AC 135 ms
105,564 KB
testcase_19 AC 134 ms
105,800 KB
testcase_20 AC 132 ms
105,672 KB
testcase_21 AC 138 ms
105,492 KB
testcase_22 AC 132 ms
105,704 KB
testcase_23 AC 134 ms
105,844 KB
testcase_24 AC 133 ms
105,692 KB
testcase_25 AC 134 ms
105,776 KB
testcase_26 AC 141 ms
105,768 KB
testcase_27 AC 134 ms
105,504 KB
testcase_28 AC 133 ms
105,796 KB
testcase_29 AC 135 ms
105,668 KB
testcase_30 AC 129 ms
105,756 KB
testcase_31 AC 133 ms
105,840 KB
testcase_32 AC 135 ms
105,656 KB
testcase_33 AC 139 ms
105,660 KB
testcase_34 AC 135 ms
105,588 KB
testcase_35 AC 142 ms
105,540 KB
testcase_36 AC 135 ms
105,664 KB
testcase_37 AC 129 ms
105,076 KB
testcase_38 AC 128 ms
104,852 KB
testcase_39 AC 132 ms
105,024 KB
testcase_40 AC 133 ms
104,956 KB
testcase_41 AC 132 ms
104,892 KB
testcase_42 AC 128 ms
105,092 KB
testcase_43 AC 131 ms
105,152 KB
testcase_44 AC 130 ms
105,116 KB
testcase_45 AC 130 ms
105,056 KB
testcase_46 AC 131 ms
104,920 KB
testcase_47 AC 128 ms
105,096 KB
testcase_48 AC 129 ms
104,892 KB
testcase_49 AC 128 ms
104,840 KB
testcase_50 AC 128 ms
104,928 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys,math,itertools
from collections import Counter,deque,defaultdict
from bisect import bisect_left,bisect_right 
from heapq import heappop,heappush,heapify
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_1(): return list(map(lambda x:int(x)-1, sys.stdin.readline().split()))
def inps(): return sys.stdin.readline()
def inpsl(x): tmp = inps(); return list(tmp[:x])
def err(x): print(x); exit()

n = inp()
a = inpl()
cnt = [0,0,0]
for x in a:
    if x >= 3: x = 3
    cnt[x-1] += 1
res = 0
res += 3*cnt[1]*cnt[0]
res += 2*cnt[0]*cnt[2]
res += 1*cnt[1]*cnt[2]
res += cnt[0]*(cnt[0]-1)
res += (cnt[1]*(cnt[1]-1) + cnt[2]*(cnt[2]-1))//2
print(res)
0