#24219: 線段樹


fire5386 (皮卡丘)

School : No School
ID : 115822
IP address : [120.106.136.77]
Last Login :
2021-04-15 12:12:30
f626. 浩杰的紅豆冰 -- wseds | From: [61.230.2.126] | Post Date : 2021-01-28 17:42

我的方法是用線段樹去建立max 跟 min segment tree

對於每個線段都去查詢最大值和最小值的差maxqry(i, i+k-1) - minqry(i, i+k-1) <= G

AC (0.7s, 61.4MB)

不過好像有點慢,不知道有沒有其他方法?

https://66lemon66.blogspot.com/2021/01/zerojudge-f626-c.html

 
#24253: Re:線段樹


fire5386 (皮卡丘)

School : No School
ID : 115822
IP address : [120.106.136.77]
Last Login :
2021-04-15 12:12:30
f626. 浩杰的紅豆冰 -- wseds | From: [61.230.43.57] | Post Date : 2021-01-31 13:58

AC (0.3s, 61.4MB)

優化後進步到0.3秒

 
ZeroJudge Forum