結果
| 問題 |
No.1470 Mex Sum
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-04-09 22:46:46 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 119 ms / 2,000 ms |
| コード長 | 522 bytes |
| コンパイル時間 | 93 ms |
| コンパイル使用メモリ | 12,416 KB |
| 実行使用メモリ | 18,568 KB |
| 最終ジャッジ日時 | 2024-06-25 06:27:28 |
| 合計ジャッジ時間 | 6,141 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 49 |
ソースコード
from collections import Counter
from sys import stdin
def main():
input = lambda: stdin.readline()[:-1]
N = int(input())
A = map(int, input().split())
nums = sorted(Counter(A).items())
one, two = 0, 0
if nums[0][0] == 1:
one = nums[0][1]
if len(nums) > 1 and nums[1][0] == 2:
two = nums[1][1]
other = N - one - two
ans = (one - 1) * one // 2 * 2
ans += one * two * 3
ans += one * other * 2
n = N - one
ans += (n - 1) * n // 2
print(ans)
main()