結果

問題 No.458 異なる素数の和
ユーザー wotsushiwotsushi
提出日時 2016-12-10 20:19:24
言語 Ruby
(3.3.0)
結果
TLE  
実行時間 -
コード長 210 bytes
コンパイル時間 372 ms
コンパイル使用メモリ 11,176 KB
実行使用メモリ 15,636 KB
最終ジャッジ日時 2023-08-19 10:28:46
合計ジャッジ時間 14,108 ms
ジャッジサーバーID
(参考情報)
judge10 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 91 ms
15,560 KB
testcase_01 AC 951 ms
15,364 KB
testcase_02 AC 1,192 ms
15,412 KB
testcase_03 AC 281 ms
15,504 KB
testcase_04 AC 358 ms
15,384 KB
testcase_05 TLE -
testcase_06 AC 1,127 ms
15,324 KB
testcase_07 AC 97 ms
15,316 KB
testcase_08 TLE -
testcase_09 AC 149 ms
15,388 KB
testcase_10 AC 89 ms
15,312 KB
testcase_11 TLE -
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 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

require "prime"

N = gets.to_i
dp = Array.new(N + 1, -Float::INFINITY)
dp[0] = 0
Prime.each(N) {|p|
  (N - p).downto(0).each {|i|
    dp[i + p] = [dp[i + p], dp[i] + 1].max
  }
}
ans = [dp[N], -1].max
puts ans
0