結果

問題 No.496 ワープクリスタル (給料日前編)
ユーザー Yuki_UtaaiYuki_Utaai
提出日時 2019-01-02 21:32:10
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 97 ms / 2,000 ms
コード長 983 bytes
コンパイル時間 185 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 11,392 KB
最終ジャッジ日時 2024-05-01 13:24:27
合計ジャッジ時間 2,095 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 25 ms
10,752 KB
testcase_01 AC 25 ms
10,880 KB
testcase_02 AC 25 ms
10,880 KB
testcase_03 AC 25 ms
10,880 KB
testcase_04 AC 25 ms
10,752 KB
testcase_05 AC 25 ms
10,880 KB
testcase_06 AC 27 ms
11,136 KB
testcase_07 AC 26 ms
10,880 KB
testcase_08 AC 42 ms
11,136 KB
testcase_09 AC 26 ms
10,752 KB
testcase_10 AC 27 ms
10,880 KB
testcase_11 AC 27 ms
10,880 KB
testcase_12 AC 29 ms
10,752 KB
testcase_13 AC 31 ms
10,880 KB
testcase_14 AC 26 ms
10,752 KB
testcase_15 AC 26 ms
10,880 KB
testcase_16 AC 27 ms
10,880 KB
testcase_17 AC 30 ms
11,136 KB
testcase_18 AC 27 ms
10,880 KB
testcase_19 AC 30 ms
10,880 KB
testcase_20 AC 27 ms
11,008 KB
testcase_21 AC 28 ms
10,752 KB
testcase_22 AC 62 ms
11,264 KB
testcase_23 AC 97 ms
11,136 KB
testcase_24 AC 51 ms
11,136 KB
testcase_25 AC 38 ms
11,392 KB
testcase_26 AC 52 ms
11,264 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

Gx, Gy, n, f = [int(_) for _ in input().split()]

xyc = []
for i in range(n):
    xyc.append([int(_) for _ in input().split()])    

cost_field = [[(i+j)*f for i in range(Gy+1)] for j in range(Gx+1)]
 
warped_xy = [[0, 0]]
for i in range(n):
    for j in range(len(warped_xy)):
        new_cost = cost_field[warped_xy[j][0]][warped_xy[j][1]] + xyc[i][2]
        try:
            if new_cost < cost_field[warped_xy[j][0] + xyc[i][0]][warped_xy[j][1]+ xyc[i][1]]:
                cost_field[warped_xy[j][0] + xyc[i][0]][warped_xy[j][1]+ xyc[i][1]] = new_cost
                cost_field[Gx][Gy] = min(cost_field[Gx][Gy], new_cost + (Gx - (warped_xy[j][0] + xyc[i][0]) + Gy - (warped_xy[j][1] + xyc[i][1]) )* f )
                
                if [warped_xy[j][0] + xyc[i][0], warped_xy[j][1]+ xyc[i][1]] not in warped_xy:
                    warped_xy.append([warped_xy[j][0] + xyc[i][0], warped_xy[j][1]+ xyc[i][1]])
            
        except: pass
      
print(cost_field[Gx][Gy])
0