結果
問題 | No.1037 exhausted |
ユーザー | ayaoni |
提出日時 | 2020-12-14 04:27:04 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,158 bytes |
コンパイル時間 | 325 ms |
コンパイル使用メモリ | 81,748 KB |
実行使用メモリ | 108,240 KB |
最終ジャッジ日時 | 2023-10-20 04:41:13 |
合計ジャッジ時間 | 4,547 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 38 ms
53,492 KB |
testcase_01 | AC | 38 ms
53,492 KB |
testcase_02 | AC | 38 ms
53,492 KB |
testcase_03 | AC | 38 ms
53,492 KB |
testcase_04 | WA | - |
testcase_05 | AC | 39 ms
53,492 KB |
testcase_06 | AC | 38 ms
53,492 KB |
testcase_07 | WA | - |
testcase_08 | AC | 38 ms
53,492 KB |
testcase_09 | AC | 38 ms
53,492 KB |
testcase_10 | AC | 38 ms
53,492 KB |
testcase_11 | AC | 38 ms
53,492 KB |
testcase_12 | AC | 182 ms
107,640 KB |
testcase_13 | AC | 182 ms
107,608 KB |
testcase_14 | AC | 183 ms
107,504 KB |
testcase_15 | AC | 181 ms
107,608 KB |
testcase_16 | AC | 183 ms
107,484 KB |
testcase_17 | AC | 189 ms
108,240 KB |
testcase_18 | AC | 179 ms
107,580 KB |
testcase_19 | AC | 180 ms
107,588 KB |
testcase_20 | AC | 124 ms
108,156 KB |
testcase_21 | AC | 73 ms
86,536 KB |
testcase_22 | AC | 94 ms
107,392 KB |
ソースコード
import sys sys.setrecursionlimit(10**7) def I(): return int(sys.stdin.readline().rstrip()) def MI(): return map(int,sys.stdin.readline().rstrip().split()) def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) def LI2(): return list(map(int,sys.stdin.readline().rstrip())) def S(): return sys.stdin.readline().rstrip() def LS(): return list(sys.stdin.readline().rstrip().split()) def LS2(): return list(sys.stdin.readline().rstrip()) N,V,L = MI() XVW = [(0,0,0)]+[tuple(MI()) for _ in range(N)] XVW.sort() inf = 10**18 dp = [[inf]*(V+1) for _ in range(N+1)] # dp[i][j] = i番目の地点に到達した際に、j以上の燃料を残すために必要な費用の最小値 for j in range(V+1): dp[0][j] = 0 for i in range(1,N+1): x,v,w = XVW[i] d = x-XVW[i-1][0] if d > V: print(-1) exit() for j in range(V+1): if j+d <= V: dp[i][j] = min(dp[i][j],dp[i-1][j+d]) if j+d-v <= V: dp[i][j] = min(dp[i][j],dp[i-1][max(j+d-v,0)]+w) y = L-XVW[-1][0] if y > V: print(-1) else: ans = dp[-1][y] if ans >= inf: print(-1) else: print(ans)