結果

問題 No.496 ワープクリスタル (給料日前編)
ユーザー miraxialmiraxial
提出日時 2017-03-24 22:44:21
言語 Ruby
(3.3.0)
結果
AC  
実行時間 92 ms / 2,000 ms
コード長 397 bytes
コンパイル時間 547 ms
コンパイル使用メモリ 11,520 KB
実行使用メモリ 16,284 KB
最終ジャッジ日時 2023-09-20 01:49:52
合計ジャッジ時間 3,645 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
15,044 KB
testcase_01 AC 79 ms
15,088 KB
testcase_02 AC 81 ms
15,032 KB
testcase_03 AC 80 ms
15,116 KB
testcase_04 AC 76 ms
15,068 KB
testcase_05 AC 76 ms
15,036 KB
testcase_06 AC 75 ms
15,244 KB
testcase_07 AC 77 ms
15,060 KB
testcase_08 AC 90 ms
15,332 KB
testcase_09 AC 92 ms
15,296 KB
testcase_10 AC 81 ms
14,996 KB
testcase_11 AC 77 ms
15,184 KB
testcase_12 AC 77 ms
15,292 KB
testcase_13 AC 77 ms
15,172 KB
testcase_14 AC 77 ms
15,296 KB
testcase_15 AC 76 ms
15,020 KB
testcase_16 AC 76 ms
15,076 KB
testcase_17 AC 78 ms
15,088 KB
testcase_18 AC 77 ms
15,080 KB
testcase_19 AC 77 ms
15,084 KB
testcase_20 AC 80 ms
15,164 KB
testcase_21 AC 80 ms
15,168 KB
testcase_22 AC 84 ms
15,824 KB
testcase_23 AC 88 ms
16,284 KB
testcase_24 AC 85 ms
15,520 KB
testcase_25 AC 83 ms
15,420 KB
testcase_26 AC 85 ms
15,588 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

gx,gy,n,cc=gets.split.map &:to_i
h={}
hh={}
n.times do
  g=gets.split.map &:to_i
  h.each do |e,v|
    if (gg0=e[0]+g[0])<=gx && (gg1=e[1]+g[1])<=gy
      gg2=[gg0,gg1]
      if hh[gg2]
        hh[gg2]=g[2]+v if hh[gg2]>g[2]+v
      else
        hh[gg2]=g[2]+v
      end
    end
  end
  hh[[g[0],g[1]]]=g[2]
  h=hh.dup
end
x=gx+gy
c=x*cc
h.each do |e,v|
  g=v+(x-e[0]-e[1])*cc
  c=g if c>g
end
p c
0