結果

問題 No.496 ワープクリスタル (給料日前編)
ユーザー 0w10w1
提出日時 2017-04-09 20:58:33
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,132 bytes
コンパイル時間 296 ms
コンパイル使用メモリ 87,144 KB
実行使用メモリ 86,016 KB
最終ジャッジ日時 2023-09-25 01:31:32
合計ジャッジ時間 6,601 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 89 ms
71,540 KB
testcase_01 AC 85 ms
71,388 KB
testcase_02 AC 85 ms
71,600 KB
testcase_03 AC 86 ms
71,768 KB
testcase_04 AC 86 ms
71,656 KB
testcase_05 AC 88 ms
71,948 KB
testcase_06 WA -
testcase_07 AC 83 ms
71,368 KB
testcase_08 AC 292 ms
84,508 KB
testcase_09 AC 277 ms
84,260 KB
testcase_10 AC 142 ms
79,708 KB
testcase_11 AC 119 ms
78,136 KB
testcase_12 AC 182 ms
80,136 KB
testcase_13 AC 193 ms
80,796 KB
testcase_14 AC 196 ms
80,664 KB
testcase_15 AC 203 ms
80,376 KB
testcase_16 AC 194 ms
81,124 KB
testcase_17 AC 211 ms
80,924 KB
testcase_18 AC 202 ms
80,568 KB
testcase_19 AC 203 ms
80,488 KB
testcase_20 AC 169 ms
79,616 KB
testcase_21 AC 166 ms
79,936 KB
testcase_22 AC 341 ms
85,756 KB
testcase_23 AC 335 ms
85,804 KB
testcase_24 AC 321 ms
85,396 KB
testcase_25 AC 319 ms
85,388 KB
testcase_26 AC 342 ms
86,016 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from copy import deepcopy

Gx, Gy, N, F = map( int, input().split() )
X = []
Y = []
C = []
for i in range( N ):
  x, y, c = map( int, input().split() )
  X.append( x )
  Y.append( y )
  C.append( c )

INF = int( 1e15 )

dp = [ INF for i in range( Gy + 1 ) ]
dp = [ deepcopy( dp ) for i in range( Gx + 1 ) ]
dp = [ deepcopy( dp ) for i in range( N + 1 ) ]
dp[ 0 ][ 0 ][ 0 ] = 0
for i in range( N ):
  for j in range( Gx + 1 ):
    for k in range( Gy + 1 ):
      dp[ i + 1 ][ j ][ k ] = min( dp[ i + 1 ][ j ][ k ], dp[ i ][ j ][ k ] )
      if j + X[ i ] <= Gx and k + Y[ i ] <= Gy:
        dp[ i + 1 ][ j + X[ i ] ][ k + Y[ i ] ] = min( dp[ i + 1 ][ j + X[ i ] ][ k + Y[ i ] ], dp[ i ][ j ][ k ] + C[ i ] )
      if j + 1 <= Gx:
        dp[ i ][ j + 1 ][ k ] = min( dp[ i ][ j + 1 ][ k ], dp[ i ][ j ][ k ] + F )
        dp[ i + 1 ][ j + 1 ][ k ] = min( dp[ i + 1 ][ j + 1 ][ k ], dp[ i ][ j ][ k ] + F )
      if k + 1 <= Gy:
        dp[ i ][ j ][ k + 1 ] = min( dp[ i ][ j ][ k + 1 ], dp[ i ][ j ][ k ] + F )
        dp[ i + 1 ][ j ][ k + 1 ] = min( dp[ i + 1 ][ j ][ k + 1 ], dp[ i ][ j ][ k ] + F )
print( dp[ N ][ Gx ][ Gy ] )
0