結果

問題 No.2930 Larger Mex
ユーザー hirayuu_ychirayuu_yc
提出日時 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
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
54,464 KB
testcase_01 AC 40 ms
55,308 KB
testcase_02 AC 39 ms
54,680 KB
testcase_03 AC 58 ms
68,128 KB
testcase_04 AC 54 ms
66,944 KB
testcase_05 AC 57 ms
66,984 KB
testcase_06 AC 55 ms
66,460 KB
testcase_07 AC 54 ms
66,160 KB
testcase_08 AC 119 ms
109,240 KB
testcase_09 AC 115 ms
105,920 KB
testcase_10 AC 120 ms
108,920 KB
testcase_11 AC 107 ms
103,792 KB
testcase_12 AC 127 ms
110,548 KB
testcase_13 AC 123 ms
109,576 KB
testcase_14 AC 122 ms
111,188 KB
testcase_15 AC 120 ms
104,356 KB
testcase_16 AC 121 ms
103,288 KB
testcase_17 AC 134 ms
109,352 KB
testcase_18 AC 124 ms
104,612 KB
testcase_19 AC 133 ms
109,568 KB
testcase_20 AC 134 ms
109,540 KB
testcase_21 AC 142 ms
109,628 KB
testcase_22 AC 127 ms
110,708 KB
testcase_23 AC 125 ms
106,340 KB
testcase_24 AC 134 ms
108,420 KB
testcase_25 AC 129 ms
111,140 KB
testcase_26 AC 113 ms
111,040 KB
testcase_27 AC 103 ms
104,388 KB
testcase_28 AC 107 ms
107,524 KB
testcase_29 AC 108 ms
107,668 KB
testcase_30 AC 108 ms
107,252 KB
testcase_31 AC 104 ms
102,316 KB
testcase_32 AC 112 ms
107,720 KB
testcase_33 AC 122 ms
107,264 KB
testcase_34 AC 139 ms
106,676 KB
testcase_35 AC 99 ms
99,440 KB
testcase_36 AC 130 ms
108,960 KB
testcase_37 AC 120 ms
106,760 KB
testcase_38 AC 132 ms
106,284 KB
testcase_39 AC 133 ms
109,012 KB
testcase_40 AC 136 ms
108,808 KB
testcase_41 AC 122 ms
106,108 KB
testcase_42 AC 109 ms
110,108 KB
testcase_43 AC 108 ms
106,976 KB
testcase_44 AC 109 ms
107,820 KB
testcase_45 AC 110 ms
107,364 KB
testcase_46 AC 124 ms
109,676 KB
testcase_47 AC 124 ms
109,612 KB
testcase_48 AC 102 ms
98,820 KB
testcase_49 AC 125 ms
109,660 KB
testcase_50 AC 132 ms
107,272 KB
testcase_51 AC 129 ms
106,780 KB
testcase_52 AC 124 ms
111,420 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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])
0