結果

問題 No.458 異なる素数の和
ユーザー hogeover30hogeover30
提出日時 2016-12-28 13:40:56
言語 Ruby
(3.3.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 149 bytes
コンパイル時間 292 ms
コンパイル使用メモリ 11,472 KB
実行使用メモリ 15,736 KB
最終ジャッジ日時 2023-08-21 18:05:13
合計ジャッジ時間 16,852 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 95 ms
15,120 KB
testcase_01 AC 744 ms
15,556 KB
testcase_02 AC 951 ms
15,376 KB
testcase_03 AC 235 ms
15,528 KB
testcase_04 AC 277 ms
15,284 KB
testcase_05 AC 1,988 ms
15,640 KB
testcase_06 AC 903 ms
15,392 KB
testcase_07 AC 98 ms
15,408 KB
testcase_08 TLE -
testcase_09 AC 136 ms
15,180 KB
testcase_10 AC 94 ms
15,196 KB
testcase_11 TLE -
testcase_12 AC 95 ms
15,508 KB
testcase_13 AC 95 ms
15,384 KB
testcase_14 AC 94 ms
15,164 KB
testcase_15 AC 96 ms
15,088 KB
testcase_16 AC 177 ms
15,584 KB
testcase_17 AC 97 ms
15,364 KB
testcase_18 AC 94 ms
15,164 KB
testcase_19 AC 95 ms
15,548 KB
testcase_20 AC 96 ms
15,308 KB
testcase_21 AC 96 ms
15,196 KB
testcase_22 AC 93 ms
15,552 KB
testcase_23 AC 95 ms
15,420 KB
testcase_24 AC 94 ms
15,292 KB
testcase_25 AC 96 ms
15,308 KB
testcase_26 AC 97 ms
15,400 KB
testcase_27 AC 854 ms
15,496 KB
testcase_28 TLE -
testcase_29 AC 117 ms
15,368 KB
testcase_30 AC 566 ms
15,520 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

require'prime'
n=gets.to_i
dp=[-1]*-~n
dp[0]=0
Prime.each(n){|p|
	(n-p).downto(0){|i|
		dp[i+p]=dp[i]+1 if dp[i]>=0 and dp[i+p]<dp[i]+1
	}
}
p dp[n]
0