Submission #3810375
Source Code Expand
#include <iostream> #include <vector> #include <queue> #include <utility> #include <math.h> #include <functional> #include <algorithm> using namespace std; typedef long long ll; ll income[100001]; ll n, m, t; struct edge{ int cost; int to; }; vector<edge> edges[100002]; vector<edge> edgesre[100002]; ll ans[100002]; ll ansre[100002]; ll monpermin[100001]; int main(){ //こっからダイクストラ法 cin >> n >> m >> t; for(ll i = 0;i < n;i ++) cin >> monpermin[i]; for(ll i = 0;i < m;i ++){ int s, t, d; cin >> s >> t >> d; edge pre = {d, t - 1}; edges[s - 1].push_back(pre); edge pre2 = {d, s - 1}; edgesre[t - 1].push_back(pre2); } for(int i = 0;i < 100002;i ++) ans[i] = 2001001001; ans[0] = 0; for(int i = 0;i < 100002;i ++) ansre[i] = 2001001001; ansre[0] = 0; typedef pair<ll, ll> P; priority_queue<P, vector<P>, greater<P> > pq; priority_queue<P, vector<P>, greater<P> > pqre; pq.push(P(0,0)); pqre.push(P(0,0)); while(!pq.empty()){ P miria = pq.top(); pq.pop(); ll r = miria.second; if(ans[r] < miria.first){ continue; } for(int i = 0;i < edges[r].size();i ++){ if(ans[edges[r][i].to] > ans[r] + edges[r][i].cost){ //今見てるとこより確定+道通るのが小さい pq.push(P(ans[r] + edges[r][i].cost, edges[r][i].to)); //その情報入れる ans[edges[r][i].to] = ans[r] + edges[r][i].cost; //更新 } } }while(!pqre.empty()){ P miria = pqre.top(); pqre.pop(); ll r = miria.second; if(ansre[r] < miria.first){ continue; } for(int i = 0;i < edgesre[r].size();i ++){ if(ansre[edgesre[r][i].to] > ansre[r] + edgesre[r][i].cost){ //今見てるとこより確定+道通るのが小さい pqre.push(P(ansre[r] + edgesre[r][i].cost, edgesre[r][i].to)); //その情報入れる ansre[edgesre[r][i].to] = ansre[r] + edgesre[r][i].cost; //更新 } } } /*for(int i = 0;i < n;i ++){ if(ans[i] < 2001001000) cout << ans[i] << endl; else cout << "INF" << endl; }*/ //ここまでダイクストラ法 for(int i = 0;i < n;i ++){ if(ans[i] < 2001001000 && ansre[i] < 2001001000) income[i] = (t - (ans[i] + ansre[i])) * monpermin[i]; else income[i] = 0; } sort(income, income + n, greater<ll>()); cout << income[0] << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | D - トレジャーハント |
User | a0t5s0u1 |
Language | C++14 (GCC 5.4.1) |
Score | 100 |
Code Size | 2376 Byte |
Status | AC |
Exec Time | 122 ms |
Memory | 14336 KB |
Judge Result
Set Name | Sample | Subtask1 | All | ||||||
---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 50 / 50 | 50 / 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 | 4 ms | 6528 KB |
00_example_02.txt | AC | 4 ms | 6528 KB |
00_example_03.txt | AC | 4 ms | 6528 KB |
10_rand_01.txt | AC | 9 ms | 6912 KB |
10_rand_02.txt | AC | 32 ms | 7680 KB |
10_rand_03.txt | AC | 12 ms | 7040 KB |
10_rand_04.txt | AC | 6 ms | 6656 KB |
10_rand_05.txt | AC | 13 ms | 7168 KB |
10_rand_06.txt | AC | 13 ms | 7040 KB |
10_rand_07.txt | AC | 18 ms | 7424 KB |
10_rand_08.txt | AC | 9 ms | 6784 KB |
10_rand_09.txt | AC | 15 ms | 7296 KB |
10_rand_10.txt | AC | 6 ms | 6656 KB |
10_rand_12.txt | AC | 52 ms | 8576 KB |
10_rand_13.txt | AC | 48 ms | 8320 KB |
30_max_01.txt | AC | 106 ms | 10620 KB |
30_max_02.txt | AC | 121 ms | 11132 KB |
30_max_03.txt | AC | 89 ms | 9856 KB |
30_max_04.txt | AC | 119 ms | 12288 KB |
30_max_05.txt | AC | 119 ms | 12288 KB |
30_max_06.txt | AC | 122 ms | 12288 KB |
40_corner_01.txt | AC | 105 ms | 14336 KB |
40_corner_02.txt | AC | 111 ms | 14336 KB |
40_corner_03.txt | AC | 113 ms | 14336 KB |
40_corner_04.txt | AC | 118 ms | 14336 KB |
50_small_01.txt | AC | 5 ms | 6528 KB |
50_small_02.txt | AC | 4 ms | 6528 KB |
50_small_03.txt | AC | 4 ms | 6528 KB |
50_small_04.txt | AC | 4 ms | 6528 KB |
50_small_05.txt | AC | 6 ms | 6528 KB |
50_small_06.txt | AC | 5 ms | 6528 KB |
50_small_07.txt | AC | 4 ms | 6528 KB |
50_small_08.txt | AC | 4 ms | 6528 KB |
50_small_09.txt | AC | 4 ms | 6528 KB |
50_small_10.txt | AC | 4 ms | 6528 KB |
60_hand_01.txt | AC | 4 ms | 6528 KB |
60_hand_02.txt | AC | 3 ms | 6528 KB |
60_hand_03.txt | AC | 4 ms | 6528 KB |
60_hand_04.txt | AC | 4 ms | 6528 KB |
70_max_01.txt | AC | 29 ms | 7424 KB |
70_max_02.txt | AC | 29 ms | 7424 KB |
70_max_03.txt | AC | 30 ms | 7424 KB |