結果

問題 No.489 株に挑戦
ユーザー むらためむらため
提出日時 2019-02-04 07:43:32
言語 Nim
(2.0.2)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,586 bytes
コンパイル時間 3,245 ms
コンパイル使用メモリ 67,152 KB
実行使用メモリ 6,864 KB
最終ジャッジ日時 2023-09-14 03:26:49
合計ジャッジ時間 4,955 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 8 ms
4,376 KB
testcase_01 AC 5 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 WA -
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 8 ms
4,536 KB
testcase_17 AC 3 ms
4,376 KB
testcase_18 AC 5 ms
4,376 KB
testcase_19 AC 5 ms
4,376 KB
testcase_20 AC 8 ms
4,552 KB
testcase_21 AC 3 ms
4,376 KB
testcase_22 AC 2 ms
4,376 KB
testcase_23 AC 6 ms
4,380 KB
testcase_24 AC 10 ms
4,816 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 7 ms
4,648 KB
testcase_28 AC 2 ms
4,376 KB
testcase_29 WA -
testcase_30 AC 10 ms
4,656 KB
testcase_31 AC 8 ms
4,644 KB
testcase_32 AC 6 ms
4,376 KB
testcase_33 AC 9 ms
4,652 KB
testcase_34 AC 8 ms
4,524 KB
testcase_35 AC 4 ms
4,376 KB
testcase_36 AC 3 ms
4,376 KB
testcase_37 AC 6 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sequtils,math,times,deques
template 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+1
  result = 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 + 1
    if l < 0:continue
    result[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': return
    result = 10 * result + k.ord - '0'.ord

let n = scan()
let d = scan()
let k = scan()
let S = newSeqWith(n,scan())
let M = S.slideMin(d+1,true)
var ans = 0
var time = 0
for i in 0..<M.len:
  let v = M[i] - S[i]
  if ans >= v : continue
  time = i
  ans = v
if ans <= 0 : quit "0",0
echo ans * k
stdout.write time," "
for i in time+1..<n:
  if S[i] == ans + S[time] :
    echo i
    break
0