結果
問題 | No.2930 Larger Mex |
ユーザー |
|
提出日時 | 2025-02-07 13:28:16 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 180 ms / 2,000 ms |
コード長 | 614 bytes |
コンパイル時間 | 563 ms |
コンパイル使用メモリ | 82,148 KB |
実行使用メモリ | 160,964 KB |
最終ジャッジ日時 | 2025-02-07 13:28:29 |
合計ジャッジ時間 | 11,067 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 50 |
ソースコード
from collections import defaultdictimport itertoolsn,m=map(int,input().split())A=list(map(int,input().split()))l,r=0,0ans=[0]*(n+1)S=set()D=defaultdict(int)if m==0:for i in range(n,0,-1):print(i)exit()while r<=n:if len(S)==m:ans[r-l-1]+=1ans[n-l]-=1if A[l]<m:D[A[l]]-=1if D[A[l]]==0:S.remove(A[l])l+=1elif len(S)<m:if r==n:breakif A[r]<m:S.add(A[r])D[A[r]]+=1r+=1ans=list(itertools.accumulate(ans))for i in ans[:-1]:print(i)