結果

問題 No.27 板の準備
ユーザー むらため
提出日時 2017-08-16 22:42:19
言語 Nim
(2.2.0)
結果
AC  
実行時間 4 ms / 5,000 ms
コード長 1,048 bytes
コンパイル時間 11,222 ms
コンパイル使用メモリ 450,236 KB
実行使用メモリ 8,192 KB
最終ジャッジ日時 2024-11-14 20:14:15
合計ジャッジ時間 12,413 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 18
権限があれば一括ダウンロードができます
コンパイルメッセージ
/home/judge/data/code/Main.nim(1, 41) Warning: Use the new 'sugar' module instead; future is deprecated [Deprecated]
/home/judge/data/code/Main.nim(1, 41) Warning: imported and not used: 'future' [UnusedImport]
/home/judge/data/code/Main.nim(1, 48) Warning: imported and not used: 'macros' [UnusedImport]

ソースコード

diff #

import sequtils,strutils,algorithm,math,future,macros
template get*():string = stdin.readLine().strip()
template `min=`*(x,y:typed):void = x = min(x,y)

let V = get().split().map(parseInt).sorted(cmp) # 4 * [1,30]
const INF = 1e6.int
var ans = INF
# 30 * 30 * 30
proc getABCCost() : array[31,array[31,array[31,array[31,int]]]] =
  for a in 0..30:
    for b in 0..30:
      for c in 0..30:
        for d in 0..30:
          result[a][b][c][d] = INF
  for A in 1..30:
    for B in 1..A:
      for C in 1..B:
        var dp = newSeqWith(30+1,INF) # v を ABC で 作るのに掛かるコストの最小値
        dp[0] = 0
        for v in 0..30-A:
          if dp[v] != INF: dp[v + A] .min= dp[v] + 1
        for v in 0..30-B:
          if dp[v] != INF: dp[v + B] .min= dp[v] + 1
        for v in 0..30-C:
          if dp[v] != INF: dp[v + C] .min= dp[v] + 1
        for v in 0..30: result[A][B][C][v] = dp[v]
const ABC = getABCCost()
for A in 1..V.max():
  for B in 1..A:
    for C in 1..B:
      ans .min= V.mapIt(ABC[A][B][C][it]).sum()
echo ans
0