結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 85 ms
71,572 KB
testcase_01 AC 85 ms
71,480 KB
testcase_02 WA -
testcase_03 AC 89 ms
71,592 KB
testcase_04 WA -
testcase_05 AC 86 ms
71,576 KB
testcase_06 WA -
testcase_07 AC 85 ms
71,688 KB
testcase_08 AC 294 ms
84,424 KB
testcase_09 AC 282 ms
84,004 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 212 ms
80,800 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
権限があれば一括ダウンロードができます

ソースコード

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 ):
      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