結果
問題 | No.1283 Extra Fee |
ユーザー | chineristAC |
提出日時 | 2020-11-06 21:39:13 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 939 bytes |
コンパイル時間 | 974 ms |
コンパイル使用メモリ | 87,040 KB |
実行使用メモリ | 119,648 KB |
最終ジャッジ日時 | 2023-09-29 18:26:38 |
合計ジャッジ時間 | 7,923 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 68 ms
71,412 KB |
testcase_01 | AC | 71 ms
71,160 KB |
testcase_02 | AC | 72 ms
71,420 KB |
testcase_03 | AC | 69 ms
71,284 KB |
testcase_04 | AC | 70 ms
71,432 KB |
testcase_05 | AC | 69 ms
71,360 KB |
testcase_06 | AC | 69 ms
71,356 KB |
testcase_07 | AC | 69 ms
71,524 KB |
testcase_08 | AC | 70 ms
71,332 KB |
testcase_09 | AC | 69 ms
71,372 KB |
testcase_10 | AC | 70 ms
71,276 KB |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | AC | 123 ms
78,520 KB |
testcase_17 | AC | 178 ms
89,224 KB |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | AC | 341 ms
112,888 KB |
testcase_24 | AC | 357 ms
115,160 KB |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | AC | 178 ms
89,484 KB |
ソースコード
N,M = map(int,input().split()) cost_s = [[0 for i in range(N)] for j in range(N)] cost_e = [[0 for i in range(N)] for j in range(N)] memo = [] for _ in range(M): h,w,c = map(int,input().split()) cost_s[h-1][w-1] = c cost_e[h-1][w-1] = c memo.append((h-1,w-1,c)) for i in range(N): for j in range(N): if i==0 and j==0: continue tmp = 10**18 if i!=0: tmp = cost_s[i-1][j] + 1 if j!=0: tmp = min(cost_s[i][j-1] + 1,tmp) cost_s[i][j] += tmp for i in range(N-1,-1,-1): for j in range(N-1,-1,-1): if i==N-1 and j==N-1: continue tmp = 10**18 if i!=N-1: tmp = cost_e[i+1][j] + 1 if j!=N-1: tmp = min(cost_e[i][j+1] + 1,tmp) cost_e[i][j] += tmp res = cost_s[N-1][N-1] for h,w,c in memo: tmp = cost_s[h][w] + cost_e[h][w] - 2*c res = min(res,tmp) print(res)