結果

問題 No.286 Modulo Discount Store
ユーザー むらためむらため
提出日時 2019-01-30 17:54:51
言語 Nim
(2.0.2)
結果
TLE  
実行時間 -
コード長 999 bytes
コンパイル時間 2,306 ms
コンパイル使用メモリ 66,416 KB
実行使用メモリ 7,236 KB
最終ジャッジ日時 2023-09-14 03:18:14
合計ジャッジ時間 6,612 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 3 ms
4,376 KB
testcase_02 TLE -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
権限があれば一括ダウンロードができます

ソースコード

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
  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