結果

問題 No.1 道のショートカット
ユーザー momoyuumomoyuu
提出日時 2022-03-07 22:29:20
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 22 ms / 5,000 ms
コード長 850 bytes
コンパイル時間 300 ms
コンパイル使用メモリ 11,060 KB
実行使用メモリ 8,968 KB
最終ジャッジ日時 2023-09-30 01:29:15
合計ジャッジ時間 4,256 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 19 ms
8,656 KB
testcase_01 AC 19 ms
8,612 KB
testcase_02 AC 18 ms
8,752 KB
testcase_03 AC 18 ms
8,616 KB
testcase_04 AC 18 ms
8,592 KB
testcase_05 AC 18 ms
8,612 KB
testcase_06 AC 18 ms
8,576 KB
testcase_07 AC 19 ms
8,564 KB
testcase_08 AC 20 ms
8,728 KB
testcase_09 AC 19 ms
8,700 KB
testcase_10 AC 19 ms
8,772 KB
testcase_11 AC 19 ms
8,780 KB
testcase_12 AC 20 ms
8,968 KB
testcase_13 AC 20 ms
8,884 KB
testcase_14 AC 18 ms
8,744 KB
testcase_15 AC 19 ms
8,648 KB
testcase_16 AC 19 ms
8,660 KB
testcase_17 AC 18 ms
8,668 KB
testcase_18 AC 18 ms
8,696 KB
testcase_19 AC 18 ms
8,584 KB
testcase_20 AC 18 ms
8,668 KB
testcase_21 AC 19 ms
8,740 KB
testcase_22 AC 19 ms
8,548 KB
testcase_23 AC 21 ms
8,780 KB
testcase_24 AC 20 ms
8,748 KB
testcase_25 AC 19 ms
8,604 KB
testcase_26 AC 19 ms
8,760 KB
testcase_27 AC 20 ms
8,892 KB
testcase_28 AC 18 ms
8,664 KB
testcase_29 AC 21 ms
8,828 KB
testcase_30 AC 19 ms
8,660 KB
testcase_31 AC 19 ms
8,688 KB
testcase_32 AC 20 ms
8,688 KB
testcase_33 AC 20 ms
8,672 KB
testcase_34 AC 22 ms
8,772 KB
testcase_35 AC 19 ms
8,688 KB
testcase_36 AC 19 ms
8,828 KB
testcase_37 AC 19 ms
8,804 KB
testcase_38 AC 18 ms
8,544 KB
testcase_39 AC 19 ms
8,624 KB
testcase_40 AC 18 ms
8,636 KB
testcase_41 AC 18 ms
8,684 KB
testcase_42 AC 18 ms
8,572 KB
testcase_43 AC 17 ms
8,724 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
C = int(input())
V = int(input())
S = list(map(int,input().split()))
T = list(map(int,input().split()))
Y = list(map(int,input().split()))
M = list(map(int,input().split()))
edge = [[] for _ in range(N)]

for i in range(V):
    edge[S[i]-1].append((T[i]-1,Y[i],M[i]))

from collections import deque

def clac(t):
    que = deque()
    que.append((0,0,0))
    while que:
        i,c,m = que.popleft()
        for j in edge[i]:
            if j[1]+c <= C and j[2]+m<=t:
                if j[0] == N-1:
                    return True
                que.append((j[0],j[1]+c,j[2]+m))
    return False

right = N *1000
left = -1
while right-left>1:
    mid = (right+left)//2
    if clac(mid):
        right = mid
    else:
        left = mid
if right == N*1000:
    print(-1)
else:
    print(right)
0