結果
| 問題 |
No.2930 Larger Mex
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-09-30 13:25:15 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 142 ms / 2,000 ms |
| コード長 | 438 bytes |
| コンパイル時間 | 318 ms |
| コンパイル使用メモリ | 82,500 KB |
| 実行使用メモリ | 111,420 KB |
| 最終ジャッジ日時 | 2024-10-12 06:39:59 |
| 合計ジャッジ時間 | 9,149 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 50 |
ソースコード
from collections import deque N,M=map(int,input().split()) A=[min(a,M) for a in list(map(int,input().split()))] less=1 cnt=[0]*(M+1) cnt[M]=1 rng=deque() ans=[0]*(N+2) for i in range(N): if cnt[A[i]]==0: less+=1 cnt[A[i]]+=1 rng.append(A[i]) while less>M: if len(rng)==0 or cnt[rng[0]]==1: break cnt[rng[0]]-=1 rng.popleft() if less>M: ans[len(rng)]+=1 ans[i+2]-=1 for i in range(N): ans[i+1]+=ans[i] print(ans[i+1])