結果
問題 | No.489 株に挑戦 |
ユーザー |
|
提出日時 | 2019-02-04 07:43:32 |
言語 | Nim (2.2.0) |
結果 |
WA
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 1,586 bytes |
コンパイル時間 | 3,268 ms |
コンパイル使用メモリ | 77,280 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-07-01 11:20:40 |
合計ジャッジ時間 | 4,562 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 WA * 1 |
other | AC * 32 WA * 3 |
ソースコード
import sequtils,math,times,dequestemplate times*(n:int,body) = (for _ in 0..<n: body)template `max=`*(x,y) = x = max(x,y)template `min=`*(x,y) = x = min(x,y)template stopwatch(body) = (let t1 = cpuTime();body;echo "TIME:",(cpuTime() - t1) * 1000,"ms")proc slideMin[T](arr:seq[T],width:int,paddingLast:bool = false) : seq[T] =let size = if paddingLast : arr.len else: arr.len-width+1result = newSeqWith(size,-1)var deq = initDeque[int]()for i in 0..<arr.len:# while deq.len > 0 and arr[deq.peekLast()] >= arr[i] : deq.popLast() # 最小値の場合while deq.len > 0 and arr[deq.peekLast()] <= arr[i] : deq.popLast() # 最大値の場合deq.addLast(i)let l = i - width + 1if l < 0:continueresult[l] = arr[deq.peekFirst()]if deq.peekFirst() == l: deq.popFirst()if not paddingLast : return# 後ろに最後の数字を詰めて同じサイズにするfor i in arr.len-width+1..<arr.len:result[i] = arr[deq.peekFirst()]if deq.peekFirst() == i: deq.popFirst()proc getchar_unlocked():char {. importc:"getchar_unlocked",header: "<stdio.h>" .}proc scan(): int =while true:let k = getchar_unlocked()if k < '0': returnresult = 10 * result + k.ord - '0'.ordlet n = scan()let d = scan()let k = scan()let S = newSeqWith(n,scan())let M = S.slideMin(d+1,true)var ans = 0var time = 0for i in 0..<M.len:let v = M[i] - S[i]if ans >= v : continuetime = ians = vif ans <= 0 : quit "0",0echo ans * kstdout.write time," "for i in time+1..<n:if S[i] == ans + S[time] :echo ibreak