結果
| 問題 | No.1470 Mex Sum |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-04-09 22:46:46 |
| 言語 | Python3 (3.14.3 + numpy 2.4.4 + scipy 1.17.1) |
| 結果 |
AC
|
| 実行時間 | 139 ms / 2,000 ms |
| + 393µs | |
| コード長 | 522 bytes |
| 記録 | |
| コンパイル時間 | 299 ms |
| コンパイル使用メモリ | 21,412 KB |
| 実行使用メモリ | 22,364 KB |
| 最終ジャッジ日時 | 2026-07-29 16:43:05 |
| 合計ジャッジ時間 | 9,177 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge3_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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()