結果

問題 No.3075 Mex Recurrence Formula
ユーザー titia
提出日時 2025-03-29 00:56:39
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
TLE  
実行時間 -
コード長 500 bytes
コンパイル時間 276 ms
コンパイル使用メモリ 12,288 KB
実行使用メモリ 10,368 KB
最終ジャッジ日時 2025-03-29 00:56:45
合計ジャッジ時間 4,985 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 5 TLE * 1 -- * 40
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

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

LIST=[0]*(N+3)

for a in A:
    if a<N+3:
        LIST[a]+=1

for j in range(N+3):
    if LIST[j]==0:
        now=j
        break

for i in range(5*N):
    A.append(now)
    LIST[now]+=1
    if A[i]<N+3:
        LIST[A[i]]-=1

        if LIST[A[i]]==0 and now>A[i]:
            now=A[i]

    while LIST[now]!=0:
        now+=1

if X-1<len(A):
    print(A[X-1])
else:
    k=X%(N+1)
    print(A[k+N])
0