Submission #8640764
Source Code Expand
#一つ目のやり方 N,M,T = map(int,input().split()) A = list(map(int,input().split())) cost = [] ans = 0 for i in range(N): L = [float('inf') for i in range(N)] cost.append(L) for i in range(M): a,b,c = map(int,input().split()) cost[a-1][b-1] = c cost_iki = [float('inf')]*N cost_kaeri = [float('inf')]*N cost_oufuku = [float('inf')]*N BOOL_iki = [0]*N BOOL_kaeri = [0]*N cost_iki[0] = 0 cost_kaeri[0] = 0 BOOL_iki[0] = 1 BOOL_kaeri[0] = 1 for i in range(N): if cost[0][i] != float('inf'): cost_iki[i] = cost[0][i] if cost[i][0] != float('inf'): cost_kaeri[i] = cost[i][0] while BOOL_iki != [1]*N: temp = 0 temp_cost = float('inf') for i in range(N): if BOOL_iki[i] != 1: if temp_cost >= cost_iki[i]: temp = i temp_cost = cost_iki[i] BOOL_iki[temp] = 1 for i in range(N): cost_iki[i] = min(cost_iki[i],cost_iki[temp]+cost[temp][i]) while BOOL_kaeri != [1]*N: temp = 0 temp_cost = float('inf') for i in range(N): if BOOL_kaeri[i] != 1: if temp_cost >= cost_kaeri[i]: temp = i temp_cost = cost_kaeri[i] BOOL_kaeri[temp] = 1 for i in range(N): cost_kaeri[i] = min(cost_kaeri[i],cost_kaeri[temp]+cost[i][temp]) for i in range(N): cost_oufuku[i] = cost_iki[i]+cost_kaeri[i] for i in range(N): ans = max(ans,(T-cost_oufuku[i])*A[i]) print(ans)
Submission Info
Submission Time | |
---|---|
Task | D - トレジャーハント |
User | Syuko4omi |
Language | Python (3.4.3) |
Score | 50 |
Code Size | 1502 Byte |
Status | TLE |
Exec Time | 3194 ms |
Memory | 564572 KB |
Judge Result
Set Name | Sample | Subtask1 | All | ||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 50 / 50 | 0 / 50 | ||||||||
Status |
|
|
|
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 | 17 ms | 3192 KB |
00_example_02.txt | AC | 17 ms | 3192 KB |
00_example_03.txt | AC | 17 ms | 3192 KB |
10_rand_01.txt | TLE | 3188 ms | 538992 KB |
10_rand_02.txt | TLE | 3189 ms | 534256 KB |
10_rand_03.txt | TLE | 3189 ms | 539816 KB |
10_rand_04.txt | TLE | 3183 ms | 437516 KB |
10_rand_05.txt | TLE | 3191 ms | 559904 KB |
10_rand_06.txt | TLE | 3191 ms | 558580 KB |
10_rand_07.txt | TLE | 3191 ms | 564572 KB |
10_rand_08.txt | TLE | 3190 ms | 543824 KB |
10_rand_09.txt | TLE | 3190 ms | 539044 KB |
10_rand_10.txt | TLE | 3189 ms | 535336 KB |
10_rand_12.txt | TLE | 3190 ms | 553076 KB |
10_rand_13.txt | TLE | 3188 ms | 550472 KB |
30_max_01.txt | TLE | 3189 ms | 551780 KB |
30_max_02.txt | TLE | 3190 ms | 554612 KB |
30_max_03.txt | TLE | 3189 ms | 530636 KB |
30_max_04.txt | TLE | 3191 ms | 553676 KB |
30_max_05.txt | TLE | 3190 ms | 551112 KB |
30_max_06.txt | TLE | 3191 ms | 563396 KB |
40_corner_01.txt | TLE | 3191 ms | 555484 KB |
40_corner_02.txt | TLE | 3191 ms | 555484 KB |
40_corner_03.txt | TLE | 3191 ms | 558556 KB |
40_corner_04.txt | TLE | 3194 ms | 557020 KB |
50_small_01.txt | AC | 24 ms | 3192 KB |
50_small_02.txt | AC | 18 ms | 3192 KB |
50_small_03.txt | AC | 33 ms | 3316 KB |
50_small_04.txt | AC | 19 ms | 3188 KB |
50_small_05.txt | AC | 33 ms | 3192 KB |
50_small_06.txt | AC | 27 ms | 3192 KB |
50_small_07.txt | AC | 32 ms | 3316 KB |
50_small_08.txt | AC | 18 ms | 3192 KB |
50_small_09.txt | AC | 23 ms | 3188 KB |
50_small_10.txt | AC | 19 ms | 3192 KB |
60_hand_01.txt | AC | 17 ms | 3192 KB |
60_hand_02.txt | AC | 17 ms | 3192 KB |
60_hand_03.txt | AC | 17 ms | 3192 KB |
60_hand_04.txt | AC | 17 ms | 3188 KB |
70_max_01.txt | AC | 192 ms | 4936 KB |
70_max_02.txt | AC | 187 ms | 4968 KB |
70_max_03.txt | AC | 187 ms | 4952 KB |