結果
問題 | No.496 ワープクリスタル (給料日前編) |
ユーザー | McGregorsh |
提出日時 | 2023-07-03 15:48:38 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 235 ms / 2,000 ms |
コード長 | 1,997 bytes |
コンパイル時間 | 377 ms |
コンパイル使用メモリ | 82,452 KB |
実行使用メモリ | 94,936 KB |
最終ジャッジ日時 | 2024-07-17 13:24:00 |
合計ジャッジ時間 | 6,533 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 140 ms
88,660 KB |
testcase_01 | AC | 138 ms
88,480 KB |
testcase_02 | AC | 137 ms
88,148 KB |
testcase_03 | AC | 139 ms
88,092 KB |
testcase_04 | AC | 139 ms
88,564 KB |
testcase_05 | AC | 138 ms
88,628 KB |
testcase_06 | AC | 140 ms
88,892 KB |
testcase_07 | AC | 137 ms
88,624 KB |
testcase_08 | AC | 202 ms
94,276 KB |
testcase_09 | AC | 206 ms
94,200 KB |
testcase_10 | AC | 167 ms
89,840 KB |
testcase_11 | AC | 159 ms
89,348 KB |
testcase_12 | AC | 187 ms
90,348 KB |
testcase_13 | AC | 190 ms
90,640 KB |
testcase_14 | AC | 198 ms
90,552 KB |
testcase_15 | AC | 183 ms
89,516 KB |
testcase_16 | AC | 185 ms
90,460 KB |
testcase_17 | AC | 193 ms
90,920 KB |
testcase_18 | AC | 191 ms
90,724 KB |
testcase_19 | AC | 197 ms
90,488 KB |
testcase_20 | AC | 173 ms
89,320 KB |
testcase_21 | AC | 174 ms
89,444 KB |
testcase_22 | AC | 227 ms
94,904 KB |
testcase_23 | AC | 235 ms
94,732 KB |
testcase_24 | AC | 228 ms
94,572 KB |
testcase_25 | AC | 227 ms
94,936 KB |
testcase_26 | AC | 232 ms
94,712 KB |
ソースコード
import sys from sys import stdin from fractions import Fraction import math from math import ceil, floor, sqrt, pi, factorial, gcd from copy import deepcopy from collections import Counter, deque, defaultdict from heapq import heapify, heappop, heappush from itertools import accumulate, product, combinations, combinations_with_replacement, permutations from bisect import bisect, bisect_left, bisect_right from functools import reduce, lru_cache from decimal import Decimal, getcontext, ROUND_HALF_UP def i_input(): return int(stdin.readline()) def i_map(): return map(int, stdin.readline().split()) def i_list(): return list(i_map()) def s_input(): return stdin.readline()[:-1] def s_map(): return s_input().split() def s_list(): return list(s_map()) def lcm(a, b): return a * b // gcd(a, b) def get_distance(x1, y1, x2, y2): d = sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2) return d def rotate(table): n_fild = [] for x in zip(*table[::-1]): n_fild.append(x) return n_fild sys.setrecursionlimit(10 ** 7) INF = float('inf') MOD = 10 ** 9 + 7 MOD2 = 998244353 alpa = 'abcdefghijklmnopqrstuvwxyz' ALPA = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' def main(): Gx, Gy, N, F = i_map() costs = [[[INF] * (Gy+1) for i in range(Gx+1)] for i in range(N+1)] costs[0][0][0] = 0 for i in range(N): x, y, c = i_map() for j in range(Gx+1): for k in range(Gy+1): costs[i+1][j][k] = min(costs[i+1][j][k], costs[i][j][k]) nx = x + j ny = y + k if not (0<=nx<=Gx and 0<=ny<=Gy): continue costs[i+1][nx][ny] = min(costs[i+1][nx][ny], costs[i][j][k] + c) #for i in costs: # print(i) ans = INF for i in range(Gx+1): for j in range(Gy+1): p = costs[-1][i][j] a = Gx - i b = Gy - j c = (a + b) * F score = c + p ans = min(ans, score) print(ans) if __name__ == '__main__': main()