結果

問題 No.286 Modulo Discount Store
ユーザー むらため
提出日時 2019-01-30 17:55:53
言語 Nim
(2.2.0)
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,014 bytes
コンパイル時間 1,190 ms
コンパイル使用メモリ 42,436 KB
最終ジャッジ日時 2025-04-21 17:35:25
合計ジャッジ時間 1,939 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。

コンパイルメッセージ
/home/judge/data/code/Main.nim(22, 25) Error: type mismatch
Expression: newSeqWith[int](1 shl n + 1, 10000000000)
  [1] 1 shl n + 1: int
  [2] 10000000000: int

Expected one of (first mismatch at [position]):
[1] template newSeqWith(len: int; init: untyped): untyped
  extra generic param given

ソースコード

diff #

import sequtils
# import algorithm,math,tables
# import sets,intsets,queues,heapqueue,bitops,strutils
# import strutils,strformat,sugar,macros
# template stopwatch(body) = (let t1 = cpuTime();body;echo "TIME:",(cpuTime() - t1) * 1000,"ms")
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 `^`(n:int) : int = (1 shl n)

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 M = newSeqWith(n,scan())
const INF = 1e10.int
var ans = INF
var dp = newSeqWith[int](^n + 1,INF)
proc solve(s,total,buyTotal:int) =
  if s == ^n - 1:
    ans .min= total
    return
  if dp[s] <= total : return
  dp[s] = total
  for x in 0..<n:
    if (^x and s ) > 0 : continue
    solve(s or ^x,total + (M[x] - (buyTotal mod 1000)).max(0),buyTotal+M[x])
solve(0,0,0)
echo ans
0