結果
| 問題 | 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 defaultdict
import itertools
n,m=map(int,input().split())
A=list(map(int,input().split()))
l,r=0,0
ans=[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]+=1
        ans[n-l]-=1
        if A[l]<m:
            D[A[l]]-=1
            if D[A[l]]==0:
                S.remove(A[l])
        l+=1
    elif len(S)<m:
        if r==n:
            break
        if A[r]<m:
            S.add(A[r])
            D[A[r]]+=1
        r+=1
ans=list(itertools.accumulate(ans))
for i in ans[:-1]:
    print(i)
            
            
            
        