結果

問題 No.2126 MEX Game
ユーザー pitPpitP
提出日時 2022-11-18 22:36:48
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 69 ms / 2,000 ms
コード長 726 bytes
コンパイル時間 465 ms
コンパイル使用メモリ 81,728 KB
実行使用メモリ 82,884 KB
最終ジャッジ日時 2023-10-20 07:33:15
合計ジャッジ時間 3,274 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
58,048 KB
testcase_01 AC 41 ms
54,228 KB
testcase_02 AC 40 ms
54,228 KB
testcase_03 AC 42 ms
58,048 KB
testcase_04 AC 40 ms
54,228 KB
testcase_05 AC 43 ms
58,048 KB
testcase_06 AC 40 ms
54,228 KB
testcase_07 AC 41 ms
54,228 KB
testcase_08 AC 40 ms
54,228 KB
testcase_09 AC 40 ms
54,228 KB
testcase_10 AC 66 ms
82,724 KB
testcase_11 AC 67 ms
82,872 KB
testcase_12 AC 68 ms
82,884 KB
testcase_13 AC 69 ms
82,884 KB
testcase_14 AC 63 ms
80,576 KB
testcase_15 AC 65 ms
80,576 KB
testcase_16 AC 63 ms
80,524 KB
testcase_17 AC 64 ms
80,240 KB
testcase_18 AC 64 ms
80,364 KB
testcase_19 AC 61 ms
79,492 KB
testcase_20 AC 61 ms
79,492 KB
testcase_21 AC 64 ms
80,576 KB
testcase_22 AC 43 ms
58,048 KB
testcase_23 AC 40 ms
54,228 KB
testcase_24 AC 43 ms
58,048 KB
testcase_25 AC 43 ms
58,048 KB
testcase_26 AC 40 ms
54,228 KB
testcase_27 AC 40 ms
54,228 KB
testcase_28 AC 44 ms
58,048 KB
testcase_29 AC 39 ms
54,228 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
cnt = [0] * (10**5+10)
A = list(map(int,input().split()))
for i in range(N):
    cnt[A[i]] += 1

r = 10**5+4
flag = True #一度だけ
res = 0
for i in range(10**5+1):
    #print(i,cnt[:5],res)
    if cnt[i] >= 2:
        res += cnt[i] - 2
    elif cnt[i] == 0:
        print(i)
        exit()
    elif flag == False: # cnt[i] == 1:
        print(i)
        exit()
    elif flag == True: # cnt[i] == 1:
        flag = False
        if res :
            cnt[i] += 1
        else:
            while r > i:
                if cnt[r] == 0:
                    r -= 1
                else:
                    cnt[r] -= 1
                    break
            else:
                print(i)
                exit()
0