結果
| 問題 |
No.2930 Larger Mex
|
| コンテスト | |
| ユーザー |
YuuuT
|
| 提出日時 | 2024-10-12 14:57:23 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 242 ms / 2,000 ms |
| コード長 | 1,119 bytes |
| コンパイル時間 | 183 ms |
| コンパイル使用メモリ | 82,664 KB |
| 実行使用メモリ | 191,096 KB |
| 最終ジャッジ日時 | 2024-10-12 14:57:34 |
| 合計ジャッジ時間 | 11,078 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 50 |
ソースコード
# oj t -c "python3 main.py"
import sys,math
from collections import defaultdict,deque
from itertools import combinations,permutations,accumulate,product
from bisect import bisect_left,bisect_right
from heapq import heappop,heappush,heapify
#from more_itertools import distinct_permutations,distinct_combinations
#from sortedcontainers import SortedList,SortedSet
def input():return sys.stdin.readline().rstrip()
def ii(): return int(input())
def ms(): return map(int, input().split())
def li(): return list(map(int,input().split()))
inf = pow(10,18)
mod = 998244353
#/////////////////////////////////
N,M = ms()
A = li()
ans = [0]*(N+2)
r = 0
tmp = set()
cnt = defaultdict(int)
for i in range(M):
tmp.add(i)
for l in range(N):
if r<l: r = l
if len(tmp)>0:
while r<N and len(tmp)>0:
cnt[A[r]] += 1
if cnt[A[r]]==1: tmp.discard(A[r])
r += 1
#print(l,r)
if len(tmp)==0:
ans[r-l] += 1
ans[N-l+1] -= 1
cnt[A[l]] -= 1
if cnt[A[l]]==0 and A[l]<M:
tmp.add(A[l])
ans = list(accumulate(ans))
for k in range(1,N+1):
print(ans[k])
YuuuT