Submission #8641310


Source Code Expand

#2つ目のやり方
import heapq
    
def dijkstra(s):
    d = [float("inf")]*N
    BOOL = [0]*N
    d[s] = 0
    BOOL[s] = 1
    P = []
    for e in edge[s]:
        heapq.heappush(P,e)
    while len(P) > 0:
        cur = heapq.heappop(P)
        if BOOL[cur[1]] == 1:
            continue
        v = cur[1]
        d[v] = cur[0]
        BOOL[v] = 1
        for e in edge[v]:
            if BOOL[e[1]] == 0:
                heapq.heappush(P,[e[0]+d[v],e[1]])
    return d
N,M,T = map(int,input().split())
A = list(map(int,input().split()))
ans = 0
edge = [[] for i in range(N)]
L = []
for i in range(M):
    a,b,c = map(int,input().split())
    L.append([a,b,c])
    edge[a-1].append([c,b-1])
iki = dijkstra(0)
edge = [[] for i in range(N)]
for i in range(M):
    edge[L[i][1]-1].append([L[i][2],L[i][0]-1])
kaeri = dijkstra(0)
for i in range(N):
    ans = max(ans,(T-iki[i]-kaeri[i])*A[i])
print(ans)

Submission Info

Submission Time
Task D - トレジャーハント
User Syuko4omi
Language Python (3.4.3)
Score 100
Code Size 942 Byte
Status AC
Exec Time 1107 ms
Memory 59168 KB

Judge Result

Set Name Sample Subtask1 All
Score / Max Score 0 / 0 50 / 50 50 / 50
Status
AC × 3
AC × 20
AC × 42
Set Name Test Cases
Sample 00_example_01.txt, 00_example_02.txt, 00_example_03.txt
Subtask1 00_example_01.txt, 00_example_02.txt, 00_example_03.txt, 50_small_01.txt, 50_small_02.txt, 50_small_03.txt, 50_small_04.txt, 50_small_05.txt, 50_small_06.txt, 50_small_07.txt, 50_small_08.txt, 50_small_09.txt, 50_small_10.txt, 60_hand_01.txt, 60_hand_02.txt, 60_hand_03.txt, 60_hand_04.txt, 70_max_01.txt, 70_max_02.txt, 70_max_03.txt
All 00_example_01.txt, 00_example_02.txt, 00_example_03.txt, 10_rand_01.txt, 10_rand_02.txt, 10_rand_03.txt, 10_rand_04.txt, 10_rand_05.txt, 10_rand_06.txt, 10_rand_07.txt, 10_rand_08.txt, 10_rand_09.txt, 10_rand_10.txt, 10_rand_12.txt, 10_rand_13.txt, 30_max_01.txt, 30_max_02.txt, 30_max_03.txt, 30_max_04.txt, 30_max_05.txt, 30_max_06.txt, 40_corner_01.txt, 40_corner_02.txt, 40_corner_03.txt, 40_corner_04.txt, 50_small_01.txt, 50_small_02.txt, 50_small_03.txt, 50_small_04.txt, 50_small_05.txt, 50_small_06.txt, 50_small_07.txt, 50_small_08.txt, 50_small_09.txt, 50_small_10.txt, 60_hand_01.txt, 60_hand_02.txt, 60_hand_03.txt, 60_hand_04.txt, 70_max_01.txt, 70_max_02.txt, 70_max_03.txt
Case Name Status Exec Time Memory
00_example_01.txt AC 18 ms 3188 KB
00_example_02.txt AC 18 ms 3188 KB
00_example_03.txt AC 18 ms 3188 KB
10_rand_01.txt AC 47 ms 6756 KB
10_rand_02.txt AC 182 ms 14388 KB
10_rand_03.txt AC 61 ms 7872 KB
10_rand_04.txt AC 29 ms 4844 KB
10_rand_05.txt AC 65 ms 9044 KB
10_rand_06.txt AC 62 ms 9820 KB
10_rand_07.txt AC 92 ms 13748 KB
10_rand_08.txt AC 43 ms 6888 KB
10_rand_09.txt AC 79 ms 11892 KB
10_rand_10.txt AC 32 ms 5104 KB
10_rand_12.txt AC 404 ms 21504 KB
10_rand_13.txt AC 327 ms 19392 KB
30_max_01.txt AC 1031 ms 41396 KB
30_max_02.txt AC 1107 ms 44780 KB
30_max_03.txt AC 1005 ms 40536 KB
30_max_04.txt AC 969 ms 54388 KB
30_max_05.txt AC 989 ms 54328 KB
30_max_06.txt AC 981 ms 54384 KB
40_corner_01.txt AC 864 ms 56764 KB
40_corner_02.txt AC 883 ms 58316 KB
40_corner_03.txt AC 890 ms 59168 KB
40_corner_04.txt AC 930 ms 59168 KB
50_small_01.txt AC 27 ms 3444 KB
50_small_02.txt AC 18 ms 3188 KB
50_small_03.txt AC 19 ms 3188 KB
50_small_04.txt AC 21 ms 3188 KB
50_small_05.txt AC 39 ms 3952 KB
50_small_06.txt AC 31 ms 3572 KB
50_small_07.txt AC 18 ms 3188 KB
50_small_08.txt AC 18 ms 3188 KB
50_small_09.txt AC 23 ms 3316 KB
50_small_10.txt AC 19 ms 3188 KB
60_hand_01.txt AC 18 ms 3188 KB
60_hand_02.txt AC 18 ms 3188 KB
60_hand_03.txt AC 18 ms 3188 KB
60_hand_04.txt AC 18 ms 3188 KB
70_max_01.txt AC 288 ms 14308 KB
70_max_02.txt AC 298 ms 14324 KB
70_max_03.txt AC 292 ms 14288 KB