結果
問題 | No.1283 Extra Fee |
ユーザー | tcltk |
提出日時 | 2021-01-21 06:42:52 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,510 bytes |
コンパイル時間 | 281 ms |
コンパイル使用メモリ | 87,156 KB |
実行使用メモリ | 107,536 KB |
最終ジャッジ日時 | 2023-08-25 18:31:49 |
合計ジャッジ時間 | 13,613 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 196 ms
83,232 KB |
testcase_01 | AC | 209 ms
83,272 KB |
testcase_02 | AC | 203 ms
83,440 KB |
testcase_03 | AC | 207 ms
83,276 KB |
testcase_04 | AC | 207 ms
83,416 KB |
testcase_05 | AC | 199 ms
83,388 KB |
testcase_06 | WA | - |
testcase_07 | AC | 194 ms
83,304 KB |
testcase_08 | AC | 201 ms
83,380 KB |
testcase_09 | WA | - |
testcase_10 | AC | 201 ms
83,240 KB |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | AC | 336 ms
90,648 KB |
testcase_16 | AC | 297 ms
88,068 KB |
testcase_17 | AC | 587 ms
106,236 KB |
testcase_18 | RE | - |
testcase_19 | RE | - |
testcase_20 | RE | - |
testcase_21 | RE | - |
testcase_22 | RE | - |
testcase_23 | AC | 469 ms
100,352 KB |
testcase_24 | RE | - |
testcase_25 | RE | - |
testcase_26 | RE | - |
testcase_27 | RE | - |
testcase_28 | RE | - |
testcase_29 | AC | 617 ms
107,536 KB |
ソースコード
#region Header #!/usr/bin/env python3 # from typing import * import sys import io import math import collections import decimal import itertools from queue import PriorityQueue import bisect import heapq def input(): return sys.stdin.readline()[:-1] sys.setrecursionlimit(1000000) #endregion # _INPUT = """3 2 # 2 2 100 # 2 3 200 # """ # sys.stdin = io.StringIO(_INPUT) def main(): N, M = map(int, input().split()) P = [[1 for _ in range(N)] for _ in range(N)] for _ in range(M): h, w, c = map(int, input().split()) h -= 1 w -= 1 P[h][w] = c + 1 dist = [[10**10 for _ in range(N)] for _ in range(N)] hq = [] heapq.heappush(hq, (0, (0, 0))) dist[0][0] = 0 path = [[None for _ in range(N)] for _ in range(N)] while hq: d, (h, w) = heapq.heappop(hq) if d > dist[h][w]: continue for (dh, dw) in [(-1, 0), (1, 0), (0, -1), (0, 1)]: (h1, w1) = (h + dh, w + dw) if 0 <= h1 <= N-1 and 0 <= w1 <= N-1: d1 = dist[h][w] + P[h1][w1] if d1 < dist[h1][w1]: dist[h1][w1] = d1 path[h1][w1] = (h, w) heapq.heappush(hq, (d1, (h1, w1))) M = 0 (h, w) = (N-1, N-1) while (h, w) != (0, 0): M = max(M, P[h][w]) (h, w) = path[h][w] print(dist[N-1][N-1] - (M - 1)) if __name__ == '__main__': main()