結果

問題 No.458 異なる素数の和
ユーザー hoktohokto
提出日時 2020-03-25 12:30:27
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 1,138 bytes
コンパイル時間 83 ms
コンパイル使用メモリ 11,364 KB
実行使用メモリ 15,644 KB
最終ジャッジ日時 2023-08-30 09:31:19
合計ジャッジ時間 14,246 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 103 ms
15,196 KB
testcase_01 AC 604 ms
15,644 KB
testcase_02 AC 751 ms
15,400 KB
testcase_03 AC 206 ms
15,296 KB
testcase_04 AC 241 ms
15,572 KB
testcase_05 AC 1,564 ms
15,328 KB
testcase_06 AC 715 ms
15,352 KB
testcase_07 AC 100 ms
15,388 KB
testcase_08 AC 1,581 ms
15,528 KB
testcase_09 AC 129 ms
15,180 KB
testcase_10 AC 100 ms
15,492 KB
testcase_11 AC 1,907 ms
15,536 KB
testcase_12 AC 100 ms
15,196 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 99 ms
15,396 KB
testcase_16 AC 159 ms
15,384 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 96 ms
15,172 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 100 ms
15,356 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 680 ms
15,564 KB
testcase_28 AC 1,820 ms
15,576 KB
testcase_29 AC 117 ms
15,100 KB
testcase_30 AC 459 ms
15,592 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

require "prime"
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

N=gets.to_i
A=Prime.each(N/4).to_a

dp=array(N+1,-1)
dp[0]=0
A.each do|a|
    (N-a).downto(0).each do|i|
      dp[i+a]=max(dp[i]+1,dp[i+a]) if dp[i]!=-1
  end
end

puts dp[N]
0