# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
153955 | 2019-09-17T14:56:25 Z | mhy908 | 날다람쥐 (JOI14_ho_t4) | C++14 | 2000 ms | 15548 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 h[100010]; LL dist[100010]; vector<int> link[100010], c[100010]; int n, m, x; int main(){ scanf("%d %d %d",&n, &m, &x); for(int i=1; i<=n; i++) scanf("%d", &h[i]); for(int i=1; i<=m; i++){ int a, b, t; scanf("%d %d %d", &a, &b, &t); if(h[a]>=t){ link[a].pb(b); c[a].pb(t); } if(h[b]>=t){ link[b].pb(a); c[b].pb(t); } } for(int i=1; i<=n; i++)dist[i]=-llinf; priority_queue<pair<LL, int> > q; q.push({-(LL)x, -1}); while(!q.empty()){ int now=-q.top().S; LL dis=-q.top().F; q.pop(); if(dist[now]>=dis)continue; dist[now]=dis; for(int i=0; i<link[now].size(); i++){ int u=link[now][i], co=c[now][i]; //printf("%lld %d\n", min(dis-co, (LL)h[u]), u); q.push({-min(dis-co, (LL)h[u]), -u}); } } //for(int i=1; i<=n; i++)printf("%lld ", dist[i]); if(dist[n]==-llinf)puts("-1"); else printf("%lld", x+h[n]-dist[n]*2); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 5112 KB | Output is correct |
2 | Correct | 153 ms | 5340 KB | Output is correct |
3 | Correct | 92 ms | 5368 KB | Output is correct |
4 | Correct | 11 ms | 5112 KB | Output is correct |
5 | Correct | 43 ms | 5112 KB | Output is correct |
6 | Correct | 7 ms | 4988 KB | Output is correct |
7 | Correct | 7 ms | 5112 KB | Output is correct |
8 | Correct | 126 ms | 5248 KB | Output is correct |
9 | Correct | 206 ms | 5112 KB | Output is correct |
10 | Correct | 194 ms | 5240 KB | Output is correct |
11 | Correct | 8 ms | 4984 KB | Output is correct |
12 | Correct | 148 ms | 5368 KB | Output is correct |
13 | Correct | 169 ms | 5288 KB | Output is correct |
14 | Correct | 17 ms | 5116 KB | Output is correct |
15 | Correct | 138 ms | 5212 KB | Output is correct |
16 | Correct | 6 ms | 5112 KB | Output is correct |
17 | Correct | 9 ms | 5084 KB | Output is correct |
18 | Correct | 9 ms | 5112 KB | Output is correct |
19 | Correct | 7 ms | 5052 KB | Output is correct |
20 | Correct | 8 ms | 5084 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 2037 ms | 15548 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 5112 KB | Output is correct |
2 | Correct | 153 ms | 5340 KB | Output is correct |
3 | Correct | 92 ms | 5368 KB | Output is correct |
4 | Correct | 11 ms | 5112 KB | Output is correct |
5 | Correct | 43 ms | 5112 KB | Output is correct |
6 | Correct | 7 ms | 4988 KB | Output is correct |
7 | Correct | 7 ms | 5112 KB | Output is correct |
8 | Correct | 126 ms | 5248 KB | Output is correct |
9 | Correct | 206 ms | 5112 KB | Output is correct |
10 | Correct | 194 ms | 5240 KB | Output is correct |
11 | Correct | 8 ms | 4984 KB | Output is correct |
12 | Correct | 148 ms | 5368 KB | Output is correct |
13 | Correct | 169 ms | 5288 KB | Output is correct |
14 | Correct | 17 ms | 5116 KB | Output is correct |
15 | Correct | 138 ms | 5212 KB | Output is correct |
16 | Correct | 6 ms | 5112 KB | Output is correct |
17 | Correct | 9 ms | 5084 KB | Output is correct |
18 | Correct | 9 ms | 5112 KB | Output is correct |
19 | Correct | 7 ms | 5052 KB | Output is correct |
20 | Correct | 8 ms | 5084 KB | Output is correct |
21 | Execution timed out | 2037 ms | 15548 KB | Time limit exceeded |
22 | Halted | 0 ms | 0 KB | - |