結果

問題 No.1470 Mex Sum
ユーザー Mitarushi
提出日時 2021-01-07 20:45:58
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 109 ms / 2,000 ms
コード長 412 bytes
コンパイル時間 268 ms
コンパイル使用メモリ 82,428 KB
実行使用メモリ 93,336 KB
最終ジャッジ日時 2024-11-14 01:17:20
合計ジャッジ時間 6,700 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 49
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
a = [int(i) for i in input().split()]
d = dict()


def mex(x, y):
    a = {x, y}
    i = 1
    while True:
        if i not in a:
            return i
        i += 1


for i in a:
    i = min(i, 3)
    if i in d:
        d[i] += 1
    else:
        d[i] = 1

ans = 0
for x, i in d.items():
    for y, j in d.items():
        ans += i*j*mex(x, y)
for i in a:
    ans -= mex(i, i)
print(ans // 2)
0