結果

問題 No.2126 MEX Game
ユーザー titiatitia
提出日時 2022-12-06 01:36:43
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 147 ms / 2,000 ms
コード長 537 bytes
コンパイル時間 115 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 25,972 KB
最終ジャッジ日時 2024-04-20 22:48:37
合計ジャッジ時間 4,665 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
11,520 KB
testcase_01 AC 78 ms
11,648 KB
testcase_02 AC 87 ms
11,648 KB
testcase_03 AC 73 ms
11,520 KB
testcase_04 AC 90 ms
11,392 KB
testcase_05 AC 82 ms
11,520 KB
testcase_06 AC 76 ms
11,520 KB
testcase_07 AC 74 ms
11,520 KB
testcase_08 AC 90 ms
11,520 KB
testcase_09 AC 83 ms
11,520 KB
testcase_10 AC 147 ms
21,996 KB
testcase_11 AC 141 ms
22,056 KB
testcase_12 AC 127 ms
22,128 KB
testcase_13 AC 131 ms
22,012 KB
testcase_14 AC 133 ms
22,336 KB
testcase_15 AC 131 ms
22,088 KB
testcase_16 AC 134 ms
21,864 KB
testcase_17 AC 136 ms
19,368 KB
testcase_18 AC 140 ms
19,744 KB
testcase_19 AC 108 ms
12,496 KB
testcase_20 AC 109 ms
12,500 KB
testcase_21 AC 123 ms
25,972 KB
testcase_22 AC 75 ms
11,520 KB
testcase_23 AC 83 ms
11,520 KB
testcase_24 AC 73 ms
11,520 KB
testcase_25 AC 76 ms
11,520 KB
testcase_26 AC 83 ms
11,520 KB
testcase_27 AC 85 ms
11,520 KB
testcase_28 AC 75 ms
11,648 KB
testcase_29 AC 74 ms
11,520 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
from collections import Counter

N=int(input())
A=list(map(int,input().split()))

C=Counter(sorted(A))

B=[C[i] for i in range(10**5)]

ind=-1
for i in range(10**5):
    if B[i]==1:
        ind=i
        break

for i in range(10**5):
    if B[i]>2 and ind!=-1:
        B[i]-=1
        B[ind]+=1
        ind=-1

for i in range(10**5-1,-1,-1):
    if B[i]>=1 and ind!=-1 and i>ind:
        B[i]-=1
        B[ind]+=1
        break

for i in range(10**5):
    if B[i]<2:
        print(i)
        break

0