# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
153917 | 2019-09-17T13:27:07 Z | mhy908 | 날다람쥐 (JOI14_ho_t4) | C++14 | 496 ms | 47668 KB |
#include <bits/stdc++.h> #define F first #define S second #define pb push_back #define mp make_pair #define llinf 8987654321987654321 #define inf 1987654321 using namespace std; typedef long long LL; typedef pair<int, int> pii; typedef pair<LL, LL> pll; int n, m; LL x; LL h[100010]; vector<pair<int, LL> > link[100010]; priority_queue<pair<LL, pair<int, LL> > > pq; LL dijk[100010]; int main() { scanf("%d %d %d", &n, &m, &x); for(int i=1; i<=n; i++)scanf("%lld", &h[i]); for(int i=1; i<=m; i++){ int a, b; LL c; scanf("%d %d %lld", &a, &b, &c); link[a].pb({b, c}); link[b].pb({a, c}); } pq.push({0, {-1, -x}}); for(int i=1; i<=n; i++)dijk[i]=llinf; while(!pq.empty()){ int here=-pq.top().S.F; LL x=-pq.top().S.S; LL c=-pq.top().F; pq.pop(); if(c>=dijk[here])continue; dijk[here]=c; for(int i=0; i<link[here].size(); i++){ int next=link[here][i].F; if(h[here]<link[here][i].S)continue; if(x>=link[here][i].S&&x-link[here][i].S>h[link[here][i].F]){ //printf("%lld %d %lld\n", c+x-h[link[here][i].F]+link[here][i].S, link[here][i].F, h[link[here][i].F]); pq.push({-(c+x-(h[link[here][i].F]+link[here][i].S)+link[here][i].S), {-link[here][i].F, -h[link[here][i].F]}}); } else if(x>=link[here][i].S){ //printf("%lld %d %lld\n", c+link[here][i].S, link[here][i].F, x-link[here][i].S); pq.push({-(c+link[here][i].S), {-link[here][i].F, -(x-link[here][i].S)}}); } else{ //printf("%lld %d %lld\n", c+link[here][i].S*2-x, link[here][i].F, 0ll); pq.push({-(c+link[here][i].S*2-x), {-link[here][i].F, 0ll}}); } } } if(dijk[n]==llinf)printf("-1"); else printf("%lld", dijk[n]+h[n]); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 2680 KB | Output is correct |
2 | Correct | 7 ms | 2936 KB | Output is correct |
3 | Correct | 11 ms | 2936 KB | Output is correct |
4 | Correct | 6 ms | 2808 KB | Output is correct |
5 | Correct | 7 ms | 2808 KB | Output is correct |
6 | Correct | 5 ms | 2680 KB | Output is correct |
7 | Correct | 5 ms | 2680 KB | Output is correct |
8 | Correct | 7 ms | 2936 KB | Output is correct |
9 | Correct | 7 ms | 2936 KB | Output is correct |
10 | Correct | 7 ms | 2936 KB | Output is correct |
11 | Correct | 5 ms | 2680 KB | Output is correct |
12 | Correct | 8 ms | 2940 KB | Output is correct |
13 | Correct | 8 ms | 2936 KB | Output is correct |
14 | Correct | 5 ms | 2808 KB | Output is correct |
15 | Correct | 6 ms | 2936 KB | Output is correct |
16 | Correct | 5 ms | 2808 KB | Output is correct |
17 | Correct | 5 ms | 2680 KB | Output is correct |
18 | Correct | 5 ms | 2808 KB | Output is correct |
19 | Correct | 5 ms | 2680 KB | Output is correct |
20 | Correct | 5 ms | 2808 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 349 ms | 26996 KB | Output is correct |
2 | Correct | 447 ms | 36688 KB | Output is correct |
3 | Correct | 200 ms | 15212 KB | Output is correct |
4 | Correct | 447 ms | 35308 KB | Output is correct |
5 | Correct | 430 ms | 47668 KB | Output is correct |
6 | Correct | 13 ms | 3832 KB | Output is correct |
7 | Correct | 299 ms | 24952 KB | Output is correct |
8 | Correct | 384 ms | 27416 KB | Output is correct |
9 | Correct | 293 ms | 24868 KB | Output is correct |
10 | Correct | 222 ms | 18948 KB | Output is correct |
11 | Correct | 32 ms | 5052 KB | Output is correct |
12 | Correct | 222 ms | 23316 KB | Output is correct |
13 | Correct | 175 ms | 25316 KB | Output is correct |
14 | Correct | 297 ms | 24776 KB | Output is correct |
15 | Correct | 11 ms | 3320 KB | Output is correct |
16 | Correct | 496 ms | 35684 KB | Output is correct |
17 | Correct | 28 ms | 4728 KB | Output is correct |
18 | Correct | 30 ms | 5112 KB | Output is correct |
19 | Correct | 107 ms | 12024 KB | Output is correct |
20 | Correct | 33 ms | 5368 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 2680 KB | Output is correct |
2 | Correct | 7 ms | 2936 KB | Output is correct |
3 | Correct | 11 ms | 2936 KB | Output is correct |
4 | Correct | 6 ms | 2808 KB | Output is correct |
5 | Correct | 7 ms | 2808 KB | Output is correct |
6 | Correct | 5 ms | 2680 KB | Output is correct |
7 | Correct | 5 ms | 2680 KB | Output is correct |
8 | Correct | 7 ms | 2936 KB | Output is correct |
9 | Correct | 7 ms | 2936 KB | Output is correct |
10 | Correct | 7 ms | 2936 KB | Output is correct |
11 | Correct | 5 ms | 2680 KB | Output is correct |
12 | Correct | 8 ms | 2940 KB | Output is correct |
13 | Correct | 8 ms | 2936 KB | Output is correct |
14 | Correct | 5 ms | 2808 KB | Output is correct |
15 | Correct | 6 ms | 2936 KB | Output is correct |
16 | Correct | 5 ms | 2808 KB | Output is correct |
17 | Correct | 5 ms | 2680 KB | Output is correct |
18 | Correct | 5 ms | 2808 KB | Output is correct |
19 | Correct | 5 ms | 2680 KB | Output is correct |
20 | Correct | 5 ms | 2808 KB | Output is correct |
21 | Correct | 349 ms | 26996 KB | Output is correct |
22 | Correct | 447 ms | 36688 KB | Output is correct |
23 | Correct | 200 ms | 15212 KB | Output is correct |
24 | Correct | 447 ms | 35308 KB | Output is correct |
25 | Correct | 430 ms | 47668 KB | Output is correct |
26 | Correct | 13 ms | 3832 KB | Output is correct |
27 | Correct | 299 ms | 24952 KB | Output is correct |
28 | Correct | 384 ms | 27416 KB | Output is correct |
29 | Correct | 293 ms | 24868 KB | Output is correct |
30 | Correct | 222 ms | 18948 KB | Output is correct |
31 | Correct | 32 ms | 5052 KB | Output is correct |
32 | Correct | 222 ms | 23316 KB | Output is correct |
33 | Correct | 175 ms | 25316 KB | Output is correct |
34 | Correct | 297 ms | 24776 KB | Output is correct |
35 | Correct | 11 ms | 3320 KB | Output is correct |
36 | Correct | 496 ms | 35684 KB | Output is correct |
37 | Correct | 28 ms | 4728 KB | Output is correct |
38 | Correct | 30 ms | 5112 KB | Output is correct |
39 | Correct | 107 ms | 12024 KB | Output is correct |
40 | Correct | 33 ms | 5368 KB | Output is correct |
41 | Correct | 252 ms | 24092 KB | Output is correct |
42 | Correct | 46 ms | 6692 KB | Output is correct |
43 | Correct | 238 ms | 20988 KB | Output is correct |
44 | Incorrect | 153 ms | 12400 KB | Output isn't correct |
45 | Halted | 0 ms | 0 KB | - |