結果
問題 | No.2930 Larger Mex |
ユーザー | prin_kemkem |
提出日時 | 2024-10-12 17:15:31 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 340 ms / 2,000 ms |
コード長 | 3,718 bytes |
コンパイル時間 | 679 ms |
コンパイル使用メモリ | 82,048 KB |
実行使用メモリ | 111,168 KB |
最終ジャッジ日時 | 2024-10-12 17:15:48 |
合計ジャッジ時間 | 15,898 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 52 ms
56,320 KB |
testcase_01 | AC | 51 ms
56,576 KB |
testcase_02 | AC | 51 ms
56,320 KB |
testcase_03 | AC | 102 ms
77,312 KB |
testcase_04 | AC | 100 ms
77,696 KB |
testcase_05 | AC | 105 ms
77,568 KB |
testcase_06 | AC | 100 ms
77,568 KB |
testcase_07 | AC | 104 ms
78,080 KB |
testcase_08 | AC | 251 ms
105,856 KB |
testcase_09 | AC | 247 ms
103,296 KB |
testcase_10 | AC | 253 ms
106,112 KB |
testcase_11 | AC | 222 ms
99,584 KB |
testcase_12 | AC | 291 ms
106,540 KB |
testcase_13 | AC | 265 ms
107,520 KB |
testcase_14 | AC | 290 ms
111,024 KB |
testcase_15 | AC | 232 ms
103,808 KB |
testcase_16 | AC | 253 ms
99,968 KB |
testcase_17 | AC | 281 ms
106,240 KB |
testcase_18 | AC | 255 ms
102,016 KB |
testcase_19 | AC | 340 ms
104,180 KB |
testcase_20 | AC | 329 ms
106,496 KB |
testcase_21 | AC | 310 ms
106,368 KB |
testcase_22 | AC | 296 ms
106,200 KB |
testcase_23 | AC | 278 ms
104,448 KB |
testcase_24 | AC | 282 ms
105,728 KB |
testcase_25 | AC | 308 ms
110,652 KB |
testcase_26 | AC | 238 ms
109,824 KB |
testcase_27 | AC | 229 ms
102,144 KB |
testcase_28 | AC | 220 ms
106,112 KB |
testcase_29 | AC | 226 ms
105,088 KB |
testcase_30 | AC | 173 ms
104,704 KB |
testcase_31 | AC | 160 ms
100,480 KB |
testcase_32 | AC | 184 ms
108,288 KB |
testcase_33 | AC | 181 ms
103,552 KB |
testcase_34 | AC | 274 ms
106,496 KB |
testcase_35 | AC | 245 ms
98,048 KB |
testcase_36 | AC | 213 ms
106,240 KB |
testcase_37 | AC | 281 ms
108,032 KB |
testcase_38 | AC | 326 ms
107,136 KB |
testcase_39 | AC | 256 ms
106,752 KB |
testcase_40 | AC | 261 ms
106,752 KB |
testcase_41 | AC | 261 ms
104,192 KB |
testcase_42 | AC | 229 ms
105,344 KB |
testcase_43 | AC | 217 ms
102,912 KB |
testcase_44 | AC | 229 ms
104,192 KB |
testcase_45 | AC | 222 ms
104,192 KB |
testcase_46 | AC | 133 ms
99,328 KB |
testcase_47 | AC | 137 ms
98,944 KB |
testcase_48 | AC | 117 ms
97,536 KB |
testcase_49 | AC | 135 ms
99,456 KB |
testcase_50 | AC | 218 ms
106,368 KB |
testcase_51 | AC | 267 ms
106,052 KB |
testcase_52 | AC | 306 ms
111,168 KB |
ソースコード
from collections import defaultdict, deque, Counter # from functools import cache # import copy from itertools import combinations, permutations, product, accumulate, groupby, chain # from more_itertools import distinct_permutations from heapq import heapify, heappop, heappush import math import bisect # from pprint import pprint from random import randint, shuffle, randrange # from sortedcontainers import SortedSet, SortedList, SortedDict import sys # sys.setrecursionlimit(2000000) input = lambda: sys.stdin.readline().rstrip('\n') inf = float('inf') mod1 = 10**9+7 mod2 = 998244353 def ceil_div(x, y): return -(-x//y) ################################################# # https://github.com/shakayami/ACL-for-python/blob/master/segtree.py class segtree(): n=1 size=1 log=2 d=[0] op=None e=10**15 def __init__(self,V,OP,E): self.n=len(V) self.op=OP self.e=E self.log=(self.n-1).bit_length() self.size=1<<self.log self.d=[E for i in range(2*self.size)] for i in range(self.n): self.d[self.size+i]=V[i] for i in range(self.size-1,0,-1): self.update(i) def set(self,p,x): assert 0<=p and p<self.n p+=self.size self.d[p]=x for i in range(1,self.log+1): self.update(p>>i) def get(self,p): assert 0<=p and p<self.n return self.d[p+self.size] def prod(self,l,r): assert 0<=l and l<=r and r<=self.n sml=self.e smr=self.e l+=self.size r+=self.size while(l<r): if (l&1): sml=self.op(sml,self.d[l]) l+=1 if (r&1): smr=self.op(self.d[r-1],smr) r-=1 l>>=1 r>>=1 return self.op(sml,smr) def all_prod(self): return self.d[1] def max_right(self,l,f): assert 0<=l and l<=self.n assert f(self.e) if l==self.n: return self.n l+=self.size sm=self.e while(1): while(l%2==0): l>>=1 if not(f(self.op(sm,self.d[l]))): while(l<self.size): l=2*l if f(self.op(sm,self.d[l])): sm=self.op(sm,self.d[l]) l+=1 return l-self.size sm=self.op(sm,self.d[l]) l+=1 if (l&-l)==l: break return self.n def min_left(self,r,f): assert 0<=r and r<=self.n assert f(self.e) if r==0: return 0 r+=self.size sm=self.e while(1): r-=1 while(r>1 and (r%2)): r>>=1 if not(f(self.op(self.d[r],sm))): while(r<self.size): r=(2*r+1) if f(self.op(self.d[r],sm)): sm=self.op(self.d[r],sm) r-=1 return r+1-self.size sm=self.op(self.d[r],sm) if (r& -r)==r: break return 0 def update(self,k): self.d[k]=self.op(self.d[2*k],self.d[2*k+1]) def __str__(self): return str([self.get(i) for i in range(self.n)]) N, M = map(int, input().split()) A = list(map(int, input().split())) if M == 0: for i in range(N, 0, -1): print(i) exit() st = segtree([-1]*M, min, inf) ans = [0]*(N+2) for i, a in enumerate(A): if a < M: st.set(a, i) l = st.prod(0, M) if l == -1: continue ans[i+1-l] += 1 ans[i+2] -= 1 for i in range(N+1): ans[i+1] += ans[i] print(*ans[1:N+1], sep="\n")