結果

問題 No.45 回転寿司
ユーザー zazaboonzazaboon
提出日時 2017-02-21 21:15:31
言語 Ruby
(3.3.0)
結果
RE  
実行時間 -
コード長 554 bytes
コンパイル時間 162 ms
コンパイル使用メモリ 11,300 KB
実行使用メモリ 96,052 KB
最終ジャッジ日時 2023-08-28 23:44:37
合計ジャッジ時間 119,442 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 WA -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 AC 2,541 ms
95,804 KB
testcase_21 AC 3,914 ms
95,840 KB
testcase_22 AC 338 ms
95,920 KB
testcase_23 AC 337 ms
96,008 KB
testcase_24 AC 452 ms
95,868 KB
testcase_25 AC 213 ms
95,120 KB
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 AC 294 ms
96,052 KB
testcase_32 WA -
testcase_33 RE -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

def inp() a=gets.chomp.split(" ").map(&:to_i);(a.size<2)? a[0]:a end
def copy(a) Marshal.load(Marshal.dump(a)) end
def kaizyo(n)(n < 2)? 1 : (2..n).inject(:*) end
def scount(a,b) a.each{|n|b[n]+=1} end
n = inp
a = inp
dp = Array.new(102){Array.new(100001,0)}
dp[0][0] = 1
n.times do |d|
  100000.times do |f|
    if(dp[d][f] != nil)
      if(dp[d][f] == 1)
        dp[d+1][f+a[d]] = 2
        dp[d+1][f] = 1
      elsif(dp[d][f] == 2)
        dp[d+1][f] = 1
      end
    end
  end
end
if(n == 1)
  p a
  exit
end
p [100000 - dp[n].reverse.index(2)].max 
0