結果
| 問題 | No.10 +か×か |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-01-30 06:30:39 |
| 言語 | Nim (2.2.6) |
| 結果 |
AC
|
| 実行時間 | 422 ms / 5,000 ms |
| コード長 | 850 bytes |
| 記録 | |
| コンパイル時間 | 2,800 ms |
| コンパイル使用メモリ | 68,048 KB |
| 実行使用メモリ | 35,356 KB |
| 最終ジャッジ日時 | 2025-12-06 14:37:47 |
| 合計ジャッジ時間 | 4,486 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 13 |
ソースコード
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].len == s.len and 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].len == s.len and next[i*a] < s) : next[i*a] = s
dp = next
echo dp[total][1..^1]