結果
| 問題 |
No.1470 Mex Sum
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-04-09 21:40:30 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 814 bytes |
| コンパイル時間 | 251 ms |
| コンパイル使用メモリ | 12,800 KB |
| 実行使用メモリ | 19,188 KB |
| 最終ジャッジ日時 | 2024-06-25 04:41:25 |
| 合計ジャッジ時間 | 16,632 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 47 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
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()