結果
問題 | No.458 異なる素数の和 |
ユーザー |
![]() |
提出日時 | 2018-04-03 07:05:53 |
言語 | Ruby (3.4.1) |
結果 |
TLE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 461 bytes |
コンパイル時間 | 62 ms |
コンパイル使用メモリ | 7,424 KB |
実行使用メモリ | 12,544 KB |
最終ジャッジ日時 | 2024-06-26 07:05:05 |
合計ジャッジ時間 | 16,937 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 24 TLE * 4 |
コンパイルメッセージ
Main.rb:34: warning: ambiguous first argument; put parentheses or a space even after `-' operator Syntax OK
ソースコード
require 'prime'n=gets.to_idp=[0]*(n+2)x=Prime.each(n).to_at=n/2+2sum=0while (x.empty? == false) && (x[0]*2<=n)e=x.shiftsum+=esum=n if sum>nt=sum-e+1t.times{|e2|p2=t-e2p3=e+p2break if p2<0next if p3>nif dp[p2]>0 && dp[p3]<dp[p2]+1dp[p3]=dp[p2]+1end}dp[e]=1 if dp[e]==0endans=dp[n]x.each{|e|p1=n-ebreak if p1<0if (dp[p1]>0 || p1==0) && ans<dp[p1]+1ans=dp[p1]+1end}if ans<1puts -1elseputs ansend