結果

問題 No.10 +か×か
ユーザー むらためむらため
提出日時 2019-01-30 06:28:17
言語 Nim
(2.0.2)
結果
WA  
実行時間 -
コード長 792 bytes
コンパイル時間 2,045 ms
コンパイル使用メモリ 69,416 KB
実行使用メモリ 39,116 KB
最終ジャッジ日時 2023-09-14 03:16:26
合計ジャッジ時間 4,893 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 772 ms
37,268 KB
testcase_04 AC 48 ms
8,296 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 740 ms
39,116 KB
testcase_07 AC 221 ms
23,140 KB
testcase_08 AC 89 ms
12,296 KB
testcase_09 WA -
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sequtils
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)
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 total = scan()
var dp = newSeqWith(total+1,"")
var next = dp
dp[scan()] = "a"
(n-1).times:
  let a = scan()
  for i in 0..total:
    if dp[i] == "": continue
    if i + a <= total:
      let s = dp[i] & '+'
      if next[i+a].len < s.len or next[i+a] < s : next[i+a] = s
    if i * a <= total:
      let s = dp[i] & '*'
      if next[i*a].len < s.len or next[i*a] < s : next[i*a] = s
  dp = next
echo dp[total][1..^1]
0