結果
問題 |
No.286 Modulo Discount Store
|
ユーザー |
|
提出日時 | 2019-01-30 17:54:51 |
言語 | Nim (2.2.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 999 bytes |
コンパイル時間 | 2,326 ms |
コンパイル使用メモリ | 61,280 KB |
実行使用メモリ | 13,756 KB |
最終ジャッジ日時 | 2024-07-01 11:12:57 |
合計ジャッジ時間 | 5,748 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | -- * 3 |
other | AC * 2 TLE * 1 -- * 37 |
ソースコード
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