結果

問題 No.1470 Mex Sum
ユーザー 8nd5t
提出日時 2021-04-09 21:35:44
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 90 ms / 2,000 ms
コード長 752 bytes
コンパイル時間 252 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 101,632 KB
最終ジャッジ日時 2024-06-25 04:28:47
合計ジャッジ時間 5,436 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 49
権限があれば一括ダウンロードができます

ソースコード

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