結果
問題 |
No.1470 Mex Sum
|
ユーザー |
|
提出日時 | 2021-04-09 21:37:29 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 869 bytes |
コンパイル時間 | 219 ms |
コンパイル使用メモリ | 12,800 KB |
実行使用メモリ | 19,196 KB |
最終ジャッジ日時 | 2024-06-25 04:34:36 |
合計ジャッジ時間 | 16,947 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 12 WA * 35 RE * 2 |
ソースコード
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 Three = 0 Other = 0 for a in A: if(a==1): One+=1 elif(a==2): Two+=1 elif(a==3): Three+=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*Three First = (N*(N-1))//2 - Thrid -Second print(3*Thrid+2*Second + First) return solve()