# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
51758 | 2018-06-21T03:29:43 Z | model_code | 날다람쥐 (JOI14_ho_t4) | C++17 | 467 ms | 30176 KB |
#include<cstdio> #include<queue> #include<vector> #include<algorithm> using namespace std; const int MAXN = 100005; const long long INF = 100001000010000100ll; // >> 10^9*10^5 int H[MAXN]; long long dist[MAXN]; vector<int> to[MAXN], cost[MAXN]; struct Dat{ long long d; int v; Dat(long long d, int v):d(d),v(v){} bool operator<(const Dat& a)const{ return d < a.d;} }; int main(){ int N, M, X, A, B, T; scanf("%d%d%d",&N,&M,&X); for(int i = 1; i <= N; i++) scanf("%d",&H[i]); for(int i = 0; i < M; i++){ scanf("%d%d%d",&A,&B,&T); to[A].push_back(B); cost[A].push_back(T); to[B].push_back(A); cost[B].push_back(T); } for(int i = 1; i <= N; i++) dist[i] = -INF; priority_queue<Dat> q; q.push(Dat(X,1)); while(!q.empty()){ Dat now = q.top(); q.pop(); if(dist[now.v] != -INF) continue; dist[now.v] = now.d; for(int i = 0; i < to[now.v].size(); i++){ int u = to[now.v][i], c = cost[now.v][i]; if(c > H[now.v]) continue; q.push(Dat(min(now.d-c, (long long)H[u]), u)); } } if(dist[N] == -INF) puts("-1"); else printf("%lld\n",X+H[N]-dist[N]*2); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 4984 KB | Output is correct |
2 | Correct | 7 ms | 5220 KB | Output is correct |
3 | Correct | 7 ms | 5272 KB | Output is correct |
4 | Correct | 6 ms | 5272 KB | Output is correct |
5 | Correct | 6 ms | 5272 KB | Output is correct |
6 | Correct | 5 ms | 5272 KB | Output is correct |
7 | Correct | 6 ms | 5272 KB | Output is correct |
8 | Correct | 10 ms | 5476 KB | Output is correct |
9 | Correct | 7 ms | 5476 KB | Output is correct |
10 | Correct | 9 ms | 5476 KB | Output is correct |
11 | Correct | 5 ms | 5476 KB | Output is correct |
12 | Correct | 7 ms | 5476 KB | Output is correct |
13 | Correct | 8 ms | 5484 KB | Output is correct |
14 | Correct | 6 ms | 5484 KB | Output is correct |
15 | Correct | 7 ms | 5484 KB | Output is correct |
16 | Correct | 6 ms | 5484 KB | Output is correct |
17 | Correct | 5 ms | 5484 KB | Output is correct |
18 | Correct | 5 ms | 5484 KB | Output is correct |
19 | Correct | 7 ms | 5484 KB | Output is correct |
20 | Correct | 6 ms | 5484 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 419 ms | 17724 KB | Output is correct |
2 | Correct | 370 ms | 22108 KB | Output is correct |
3 | Correct | 231 ms | 22108 KB | Output is correct |
4 | Correct | 402 ms | 23096 KB | Output is correct |
5 | Correct | 352 ms | 30176 KB | Output is correct |
6 | Correct | 13 ms | 30176 KB | Output is correct |
7 | Correct | 338 ms | 30176 KB | Output is correct |
8 | Correct | 402 ms | 30176 KB | Output is correct |
9 | Correct | 318 ms | 30176 KB | Output is correct |
10 | Correct | 252 ms | 30176 KB | Output is correct |
11 | Correct | 32 ms | 30176 KB | Output is correct |
12 | Correct | 213 ms | 30176 KB | Output is correct |
13 | Correct | 114 ms | 30176 KB | Output is correct |
14 | Correct | 369 ms | 30176 KB | Output is correct |
15 | Correct | 12 ms | 30176 KB | Output is correct |
16 | Correct | 290 ms | 30176 KB | Output is correct |
17 | Correct | 34 ms | 30176 KB | Output is correct |
18 | Correct | 41 ms | 30176 KB | Output is correct |
19 | Correct | 138 ms | 30176 KB | Output is correct |
20 | Correct | 44 ms | 30176 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 4984 KB | Output is correct |
2 | Correct | 7 ms | 5220 KB | Output is correct |
3 | Correct | 7 ms | 5272 KB | Output is correct |
4 | Correct | 6 ms | 5272 KB | Output is correct |
5 | Correct | 6 ms | 5272 KB | Output is correct |
6 | Correct | 5 ms | 5272 KB | Output is correct |
7 | Correct | 6 ms | 5272 KB | Output is correct |
8 | Correct | 10 ms | 5476 KB | Output is correct |
9 | Correct | 7 ms | 5476 KB | Output is correct |
10 | Correct | 9 ms | 5476 KB | Output is correct |
11 | Correct | 5 ms | 5476 KB | Output is correct |
12 | Correct | 7 ms | 5476 KB | Output is correct |
13 | Correct | 8 ms | 5484 KB | Output is correct |
14 | Correct | 6 ms | 5484 KB | Output is correct |
15 | Correct | 7 ms | 5484 KB | Output is correct |
16 | Correct | 6 ms | 5484 KB | Output is correct |
17 | Correct | 5 ms | 5484 KB | Output is correct |
18 | Correct | 5 ms | 5484 KB | Output is correct |
19 | Correct | 7 ms | 5484 KB | Output is correct |
20 | Correct | 6 ms | 5484 KB | Output is correct |
21 | Correct | 419 ms | 17724 KB | Output is correct |
22 | Correct | 370 ms | 22108 KB | Output is correct |
23 | Correct | 231 ms | 22108 KB | Output is correct |
24 | Correct | 402 ms | 23096 KB | Output is correct |
25 | Correct | 352 ms | 30176 KB | Output is correct |
26 | Correct | 13 ms | 30176 KB | Output is correct |
27 | Correct | 338 ms | 30176 KB | Output is correct |
28 | Correct | 402 ms | 30176 KB | Output is correct |
29 | Correct | 318 ms | 30176 KB | Output is correct |
30 | Correct | 252 ms | 30176 KB | Output is correct |
31 | Correct | 32 ms | 30176 KB | Output is correct |
32 | Correct | 213 ms | 30176 KB | Output is correct |
33 | Correct | 114 ms | 30176 KB | Output is correct |
34 | Correct | 369 ms | 30176 KB | Output is correct |
35 | Correct | 12 ms | 30176 KB | Output is correct |
36 | Correct | 290 ms | 30176 KB | Output is correct |
37 | Correct | 34 ms | 30176 KB | Output is correct |
38 | Correct | 41 ms | 30176 KB | Output is correct |
39 | Correct | 138 ms | 30176 KB | Output is correct |
40 | Correct | 44 ms | 30176 KB | Output is correct |
41 | Correct | 314 ms | 30176 KB | Output is correct |
42 | Correct | 62 ms | 30176 KB | Output is correct |
43 | Correct | 287 ms | 30176 KB | Output is correct |
44 | Correct | 181 ms | 30176 KB | Output is correct |
45 | Correct | 406 ms | 30176 KB | Output is correct |
46 | Correct | 26 ms | 30176 KB | Output is correct |
47 | Correct | 433 ms | 30176 KB | Output is correct |
48 | Correct | 456 ms | 30176 KB | Output is correct |
49 | Correct | 338 ms | 30176 KB | Output is correct |
50 | Correct | 397 ms | 30176 KB | Output is correct |
51 | Correct | 47 ms | 30176 KB | Output is correct |
52 | Correct | 385 ms | 30176 KB | Output is correct |
53 | Correct | 355 ms | 30176 KB | Output is correct |
54 | Correct | 356 ms | 30176 KB | Output is correct |
55 | Correct | 393 ms | 30176 KB | Output is correct |
56 | Correct | 467 ms | 30176 KB | Output is correct |
57 | Correct | 81 ms | 30176 KB | Output is correct |
58 | Correct | 11 ms | 30176 KB | Output is correct |
59 | Correct | 391 ms | 30176 KB | Output is correct |
60 | Correct | 76 ms | 30176 KB | Output is correct |