# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
95754 |
2019-02-02T10:34:11 Z |
easrui |
None (JOI14_ho_t4) |
C++14 |
|
299 ms |
25428 KB |
#include <bits/stdc++.h>
#define va first
#define vb second
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pii;
const int MN = 1e5+5;
long long N,M,X,H[MN],a,b,t,pos,len,dis,D[MN],h,ans;
vector<pii> G[MN];
struct node{
ll a,d;
node(){};
node(ll x, ll y){a = x, d = y;};
bool operator < (const node &A) const{
return A.d<d;
}
};
priority_queue<node> pq;
int main()
{
//freopen("input.txt","r",stdin);
ios_base::sync_with_stdio(0),cin.tie(0);
cin >> N >> M >> X;
for(int i=1; i<=N; i++) cin >> H[i];
for(int i=0; i<M; i++){
cin >> a >> b >> t;
if(H[a]>=t) G[a].push_back(pii(t,b));
if(H[b]>=t) G[b].push_back(pii(t,a));
}
for(int i=1; i<=N; i++) D[i] = 1e16;
D[1] = 0;
pq.push(node(1,0));
while(!pq.empty()){
pos = pq.top().a;
len = pq.top().d;
pq.pop();
if(len>D[pos]) continue;
for(pii cur : G[pos]){
if(len<X){
h = X - len;
if(h<cur.va) dis = len + cur.va + (cur.va-h);
else if(h>H[cur.vb]+cur.va) dis = X - H[cur.vb];
else dis = len + cur.va;
} else dis = len + 2*cur.va;
if(dis<D[cur.vb]){
D[cur.vb] = dis;
pq.push(node(cur.vb,dis));
}
}
}
ans = D[N]+H[N]+min(D[N]-X,0ll);
if(D[N]==1e16) ans = -1;
cout << ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
2808 KB |
Output is correct |
2 |
Correct |
5 ms |
2808 KB |
Output is correct |
3 |
Correct |
5 ms |
2808 KB |
Output is correct |
4 |
Correct |
4 ms |
2684 KB |
Output is correct |
5 |
Correct |
4 ms |
2808 KB |
Output is correct |
6 |
Correct |
4 ms |
2680 KB |
Output is correct |
7 |
Correct |
4 ms |
2680 KB |
Output is correct |
8 |
Correct |
5 ms |
2808 KB |
Output is correct |
9 |
Correct |
5 ms |
2808 KB |
Output is correct |
10 |
Correct |
5 ms |
2808 KB |
Output is correct |
11 |
Correct |
4 ms |
2680 KB |
Output is correct |
12 |
Correct |
5 ms |
2808 KB |
Output is correct |
13 |
Correct |
5 ms |
2808 KB |
Output is correct |
14 |
Correct |
4 ms |
2808 KB |
Output is correct |
15 |
Correct |
5 ms |
2808 KB |
Output is correct |
16 |
Correct |
4 ms |
2780 KB |
Output is correct |
17 |
Correct |
4 ms |
2680 KB |
Output is correct |
18 |
Correct |
4 ms |
2808 KB |
Output is correct |
19 |
Correct |
4 ms |
2680 KB |
Output is correct |
20 |
Correct |
4 ms |
2808 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
180 ms |
8616 KB |
Output is correct |
2 |
Correct |
198 ms |
25428 KB |
Output is correct |
3 |
Correct |
168 ms |
13864 KB |
Output is correct |
4 |
Correct |
238 ms |
23536 KB |
Output is correct |
5 |
Correct |
167 ms |
24172 KB |
Output is correct |
6 |
Correct |
9 ms |
2936 KB |
Output is correct |
7 |
Correct |
93 ms |
9592 KB |
Output is correct |
8 |
Correct |
248 ms |
21192 KB |
Output is correct |
9 |
Correct |
120 ms |
11708 KB |
Output is correct |
10 |
Correct |
67 ms |
8312 KB |
Output is correct |
11 |
Correct |
19 ms |
4824 KB |
Output is correct |
12 |
Correct |
123 ms |
14336 KB |
Output is correct |
13 |
Correct |
55 ms |
12920 KB |
Output is correct |
14 |
Correct |
100 ms |
10488 KB |
Output is correct |
15 |
Correct |
8 ms |
3320 KB |
Output is correct |
16 |
Correct |
144 ms |
23548 KB |
Output is correct |
17 |
Correct |
19 ms |
4668 KB |
Output is correct |
18 |
Correct |
23 ms |
4984 KB |
Output is correct |
19 |
Correct |
41 ms |
5896 KB |
Output is correct |
20 |
Correct |
21 ms |
5240 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
2808 KB |
Output is correct |
2 |
Correct |
5 ms |
2808 KB |
Output is correct |
3 |
Correct |
5 ms |
2808 KB |
Output is correct |
4 |
Correct |
4 ms |
2684 KB |
Output is correct |
5 |
Correct |
4 ms |
2808 KB |
Output is correct |
6 |
Correct |
4 ms |
2680 KB |
Output is correct |
7 |
Correct |
4 ms |
2680 KB |
Output is correct |
8 |
Correct |
5 ms |
2808 KB |
Output is correct |
9 |
Correct |
5 ms |
2808 KB |
Output is correct |
10 |
Correct |
5 ms |
2808 KB |
Output is correct |
11 |
Correct |
4 ms |
2680 KB |
Output is correct |
12 |
Correct |
5 ms |
2808 KB |
Output is correct |
13 |
Correct |
5 ms |
2808 KB |
Output is correct |
14 |
Correct |
4 ms |
2808 KB |
Output is correct |
15 |
Correct |
5 ms |
2808 KB |
Output is correct |
16 |
Correct |
4 ms |
2780 KB |
Output is correct |
17 |
Correct |
4 ms |
2680 KB |
Output is correct |
18 |
Correct |
4 ms |
2808 KB |
Output is correct |
19 |
Correct |
4 ms |
2680 KB |
Output is correct |
20 |
Correct |
4 ms |
2808 KB |
Output is correct |
21 |
Correct |
180 ms |
8616 KB |
Output is correct |
22 |
Correct |
198 ms |
25428 KB |
Output is correct |
23 |
Correct |
168 ms |
13864 KB |
Output is correct |
24 |
Correct |
238 ms |
23536 KB |
Output is correct |
25 |
Correct |
167 ms |
24172 KB |
Output is correct |
26 |
Correct |
9 ms |
2936 KB |
Output is correct |
27 |
Correct |
93 ms |
9592 KB |
Output is correct |
28 |
Correct |
248 ms |
21192 KB |
Output is correct |
29 |
Correct |
120 ms |
11708 KB |
Output is correct |
30 |
Correct |
67 ms |
8312 KB |
Output is correct |
31 |
Correct |
19 ms |
4824 KB |
Output is correct |
32 |
Correct |
123 ms |
14336 KB |
Output is correct |
33 |
Correct |
55 ms |
12920 KB |
Output is correct |
34 |
Correct |
100 ms |
10488 KB |
Output is correct |
35 |
Correct |
8 ms |
3320 KB |
Output is correct |
36 |
Correct |
144 ms |
23548 KB |
Output is correct |
37 |
Correct |
19 ms |
4668 KB |
Output is correct |
38 |
Correct |
23 ms |
4984 KB |
Output is correct |
39 |
Correct |
41 ms |
5896 KB |
Output is correct |
40 |
Correct |
21 ms |
5240 KB |
Output is correct |
41 |
Correct |
88 ms |
9236 KB |
Output is correct |
42 |
Correct |
26 ms |
6008 KB |
Output is correct |
43 |
Correct |
73 ms |
8056 KB |
Output is correct |
44 |
Correct |
76 ms |
11380 KB |
Output is correct |
45 |
Correct |
299 ms |
23060 KB |
Output is correct |
46 |
Correct |
14 ms |
4856 KB |
Output is correct |
47 |
Correct |
207 ms |
21076 KB |
Output is correct |
48 |
Correct |
264 ms |
22008 KB |
Output is correct |
49 |
Correct |
215 ms |
18548 KB |
Output is correct |
50 |
Correct |
230 ms |
24044 KB |
Output is correct |
51 |
Correct |
27 ms |
5752 KB |
Output is correct |
52 |
Correct |
178 ms |
17520 KB |
Output is correct |
53 |
Correct |
97 ms |
10140 KB |
Output is correct |
54 |
Correct |
119 ms |
11768 KB |
Output is correct |
55 |
Correct |
114 ms |
10504 KB |
Output is correct |
56 |
Correct |
273 ms |
22740 KB |
Output is correct |
57 |
Correct |
48 ms |
7928 KB |
Output is correct |
58 |
Correct |
8 ms |
3192 KB |
Output is correct |
59 |
Correct |
90 ms |
9688 KB |
Output is correct |
60 |
Correct |
46 ms |
7800 KB |
Output is correct |