Submission #54864448


Source Code Expand

Copy
import networkx as nx
N, M, T = map(int, input().split())
A = tuple(map(int, input().split()))
G = nx.DiGraph()
G.add_nodes_from(range(1, N + 1))
G.add_weighted_edges_from([map(int, input().split()) for _ in range(M)])
L = nx.single_source_dijkstra_path_length(G, 1)
G_inv = G.reverse(copy=False)
L_inv = nx.single_source_dijkstra_path_length(G_inv, 1)
ans = 0
for i in range(1, N + 1):
if i in L and i in L_inv:
ans = max(ans, (T - L[i] - L_inv[i]) * A[i - 1])
print(ans)
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
import networkx as nx

N, M, T = map(int, input().split())
A = tuple(map(int, input().split()))

G = nx.DiGraph()
G.add_nodes_from(range(1, N + 1))
G.add_weighted_edges_from([map(int, input().split()) for _ in range(M)])
L = nx.single_source_dijkstra_path_length(G, 1)

G_inv = G.reverse(copy=False)
L_inv = nx.single_source_dijkstra_path_length(G_inv, 1)

ans = 0
for i in range(1, N + 1):
    if i in L and i in L_inv:
        ans = max(ans, (T - L[i] - L_inv[i]) * A[i - 1])
print(ans)

Submission Info

Submission Time
Task D - トレジャーハント
User H3PO4
Language Python (CPython 3.11.4)
Score 100
Code Size 507 Byte
Status AC
Exec Time 1085 ms
Memory 181688 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 115 ms 28748 KB
00_example_02.txt AC 116 ms 28656 KB
00_example_03.txt AC 114 ms 28708 KB
10_rand_01.txt AC 142 ms 36720 KB
10_rand_02.txt AC 273 ms 53952 KB
10_rand_03.txt AC 155 ms 39160 KB
10_rand_04.txt AC 123 ms 32620 KB
10_rand_05.txt AC 160 ms 42500 KB
10_rand_06.txt AC 157 ms 42176 KB
10_rand_07.txt AC 178 ms 51520 KB
10_rand_08.txt AC 141 ms 38584 KB
10_rand_09.txt AC 168 ms 48884 KB
10_rand_10.txt AC 124 ms 33836 KB
10_rand_12.txt AC 435 ms 67468 KB
10_rand_13.txt AC 386 ms 64756 KB
30_max_01.txt AC 861 ms 105892 KB
30_max_02.txt AC 1085 ms 118252 KB
30_max_03.txt AC 747 ms 99988 KB
30_max_04.txt AC 901 ms 149336 KB
30_max_05.txt AC 901 ms 149260 KB
30_max_06.txt AC 861 ms 149512 KB
40_corner_01.txt AC 742 ms 168616 KB
40_corner_02.txt AC 751 ms 178904 KB
40_corner_03.txt AC 741 ms 181688 KB
40_corner_04.txt AC 791 ms 178092 KB
50_small_01.txt AC 115 ms 29520 KB
50_small_02.txt AC 109 ms 28712 KB
50_small_03.txt AC 112 ms 28892 KB
50_small_04.txt AC 112 ms 28900 KB
50_small_05.txt AC 120 ms 30564 KB
50_small_06.txt AC 118 ms 29972 KB
50_small_07.txt AC 109 ms 28840 KB
50_small_08.txt AC 109 ms 28756 KB
50_small_09.txt AC 114 ms 29468 KB
50_small_10.txt AC 112 ms 28884 KB
60_hand_01.txt AC 110 ms 28788 KB
60_hand_02.txt AC 113 ms 28808 KB
60_hand_03.txt AC 110 ms 28912 KB
60_hand_04.txt AC 110 ms 28684 KB
70_max_01.txt AC 265 ms 53548 KB
70_max_02.txt AC 256 ms 53732 KB
70_max_03.txt AC 274 ms 53640 KB


2025-04-05 (Sat)
10:15:22 +00:00