Submission #677153
Source Code Expand
#include <algorithm>
#include <array>
#include <complex>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
inline bool valid(const int x, const int r) { return 0 <= x && x < r; }
void initIOStream() {
ios::sync_with_stdio(false); // stdinなどと同期しない
cin.tie(0); // cinの前にflushしない
cout.setf(ios::fixed);
cout.precision(10); // 四捨五入して指定桁数表示
}
typedef pair<ll, ll> P;
const int MAX_N = 100000;
const ll INF = 1LL << 60;
vector<P> G[MAX_N];
vector<P> G2[MAX_N];
ll dist[MAX_N];
ll dist2[MAX_N];
void dijkstra(){
fill(dist, dist+MAX_N, INF);
dist[0] = 0;
priority_queue<P, vector<P>, greater<P> > q;
q.push(make_pair(0, 0));
while(!q.empty()){
auto p = q.top();
q.pop();
ll u = p.second;
if(dist[u] < p.first) continue;
for(int i = 0; i < G[u].size(); ++i){
ll v = G[u][i].first;
ll cost = p.first + G[u][i].second;
if(dist[v] > cost){
dist[v] = cost;
q.push(make_pair(v, dist[v]));
}
}
}
}
void dijkstra2(){
fill(dist2, dist2+MAX_N, INF);
dist2[0] = 0;
priority_queue<P, vector<P>, greater<P> > q;
q.push(make_pair(0, 0));
while(!q.empty()){
auto p = q.top();
q.pop();
ll u = p.second;
if(dist2[u] < p.first) continue;
for(int i = 0; i < G2[u].size(); ++i){
ll v = G2[u][i].first;
ll cost = p.first + G2[u][i].second;
if(dist2[v] > cost){
dist2[v] = cost;
q.push(make_pair(v, dist2[v]));
}
}
}
}
int main() {
initIOStream();
ll N, M, T;
cin >> N >> M >> T;
vector<ll> A(N);
for(int i = 0; i < N; ++i) {
cin >> A[i];
}
for(int i = 0; i < M; ++i) {
ll a, b, c;
cin >> a >> b >> c;
--a; --b;
G[a].emplace_back(b, c);
G2[b].emplace_back(a, c);
}
dijkstra();
dijkstra2();
ll ans = 0;
for(int i = 0; i < N; ++i) {
ll t = T - (dist[i] + dist2[i]);
if(t > 0){
ans = max(ans, A[i] * t);
}
}
cout << ans << endl;
}
Submission Info
| Submission Time | |
|---|---|
| Task | D - トレジャーハント |
| User | lawel3110 |
| Language | C++14 (GCC 5.4.1) |
| Score | 0 |
| Code Size | 2456 Byte |
| Status | WA |
| Exec Time | 289 ms |
| Memory | 13568 KiB |
Judge Result
| Set Name | Sample | Subtask1 | All | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 0 / 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 | 15 ms | 6528 KiB |
| 00_example_02.txt | AC | 13 ms | 6528 KiB |
| 00_example_03.txt | WA | 13 ms | 6528 KiB |
| 10_rand_01.txt | AC | 17 ms | 6784 KiB |
| 10_rand_02.txt | AC | 34 ms | 7936 KiB |
| 10_rand_03.txt | AC | 19 ms | 6912 KiB |
| 10_rand_04.txt | AC | 15 ms | 6656 KiB |
| 10_rand_05.txt | AC | 20 ms | 6912 KiB |
| 10_rand_06.txt | AC | 20 ms | 6784 KiB |
| 10_rand_07.txt | AC | 24 ms | 7040 KiB |
| 10_rand_08.txt | AC | 18 ms | 6656 KiB |
| 10_rand_09.txt | AC | 21 ms | 6912 KiB |
| 10_rand_10.txt | AC | 17 ms | 6656 KiB |
| 10_rand_12.txt | WA | 59 ms | 9088 KiB |
| 10_rand_13.txt | WA | 53 ms | 8832 KiB |
| 30_max_01.txt | WA | 102 ms | 12152 KiB |
| 30_max_02.txt | WA | 118 ms | 12308 KiB |
| 30_max_03.txt | AC | 86 ms | 12060 KiB |
| 30_max_04.txt | RE | 289 ms | 11776 KiB |
| 30_max_05.txt | AC | 116 ms | 12672 KiB |
| 30_max_06.txt | AC | 110 ms | 12672 KiB |
| 40_corner_01.txt | AC | 88 ms | 13568 KiB |
| 40_corner_02.txt | WA | 90 ms | 13568 KiB |
| 40_corner_03.txt | WA | 99 ms | 13568 KiB |
| 40_corner_04.txt | RE | 270 ms | 12800 KiB |
| 50_small_01.txt | AC | 14 ms | 6656 KiB |
| 50_small_02.txt | AC | 14 ms | 6528 KiB |
| 50_small_03.txt | AC | 14 ms | 6528 KiB |
| 50_small_04.txt | AC | 14 ms | 6528 KiB |
| 50_small_05.txt | AC | 17 ms | 6656 KiB |
| 50_small_06.txt | WA | 15 ms | 6656 KiB |
| 50_small_07.txt | AC | 14 ms | 6528 KiB |
| 50_small_08.txt | AC | 14 ms | 6528 KiB |
| 50_small_09.txt | WA | 15 ms | 6528 KiB |
| 50_small_10.txt | WA | 14 ms | 6528 KiB |
| 60_hand_01.txt | AC | 13 ms | 6528 KiB |
| 60_hand_02.txt | AC | 13 ms | 6528 KiB |
| 60_hand_03.txt | AC | 13 ms | 6528 KiB |
| 60_hand_04.txt | AC | 13 ms | 6528 KiB |
| 70_max_01.txt | WA | 34 ms | 8320 KiB |
| 70_max_02.txt | AC | 33 ms | 8320 KiB |
| 70_max_03.txt | WA | 33 ms | 8320 KiB |