Submission #677414


Source Code Expand

#include <iostream>

#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/dijkstra_shortest_paths.hpp>

using namespace std;
using namespace boost;

int main() {
  int n, m, t;
  cin >> n >> m >> t;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) cin >> a[i];
  adjacency_list<listS, vecS, directedS, no_property, property<edge_weight_t, long long>> graph1(n), graph2(n);
  for (int i = 0; i < m; ++i) {
    int a, b, c;
    cin >> a >> b >> c;
    --a, --b;
    add_edge(a, b, c, graph1);
    add_edge(b, a, c, graph2);
  }

  vector<long long> distances1(n), distances2(n);
  vector<int> parents1(n), parents2(n);
  dijkstra_shortest_paths(graph1, 0, distance_map(distances1.data()).predecessor_map(parents1.data()));
  dijkstra_shortest_paths(graph2, 0, distance_map(distances2.data()).predecessor_map(parents2.data()));

  long long res = 0;
  for (int i = 0; i < n; ++i) {
    if (i != 0 && (parents1[i] == i || parents2[i] == i)) continue;
    res = max(res, a[i] * (t - distances1[i] - distances2[i]));
  }
  cout << res << endl;
}

Submission Info

Submission Time
Task D - トレジャーハント
User not
Language C++14 (GCC 5.4.1)
Score 100
Code Size 1086 Byte
Status AC
Exec Time 305 ms
Memory 24064 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 4 ms 256 KB
00_example_02.txt AC 4 ms 256 KB
00_example_03.txt AC 4 ms 256 KB
10_rand_01.txt AC 16 ms 1920 KB
10_rand_02.txt AC 69 ms 5504 KB
10_rand_03.txt AC 24 ms 2536 KB
10_rand_04.txt AC 9 ms 1024 KB
10_rand_05.txt AC 31 ms 3100 KB
10_rand_06.txt AC 26 ms 3456 KB
10_rand_07.txt AC 37 ms 5168 KB
10_rand_08.txt AC 16 ms 2048 KB
10_rand_09.txt AC 32 ms 4480 KB
10_rand_10.txt AC 11 ms 1280 KB
10_rand_12.txt AC 109 ms 8576 KB
10_rand_13.txt AC 99 ms 7808 KB
30_max_01.txt AC 241 ms 17464 KB
30_max_02.txt AC 287 ms 19328 KB
30_max_03.txt AC 215 ms 16492 KB
30_max_04.txt AC 294 ms 24064 KB
30_max_05.txt AC 305 ms 24064 KB
30_max_06.txt AC 288 ms 24064 KB
40_corner_01.txt AC 240 ms 24064 KB
40_corner_02.txt AC 255 ms 24064 KB
40_corner_03.txt AC 269 ms 24064 KB
40_corner_04.txt AC 268 ms 24064 KB
50_small_01.txt AC 7 ms 512 KB
50_small_02.txt AC 4 ms 256 KB
50_small_03.txt AC 4 ms 256 KB
50_small_04.txt AC 5 ms 384 KB
50_small_05.txt AC 10 ms 768 KB
50_small_06.txt AC 10 ms 640 KB
50_small_07.txt AC 4 ms 256 KB
50_small_08.txt AC 4 ms 256 KB
50_small_09.txt AC 5 ms 384 KB
50_small_10.txt AC 4 ms 256 KB
60_hand_01.txt AC 4 ms 256 KB
60_hand_02.txt AC 8 ms 384 KB
60_hand_03.txt AC 4 ms 256 KB
60_hand_04.txt AC 4 ms 256 KB
70_max_01.txt AC 76 ms 6528 KB
70_max_02.txt AC 76 ms 6528 KB
70_max_03.txt AC 77 ms 6528 KB