# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
86573 | 2018-11-26T16:15:57 Z | tjdgus4384 | None (KOI16_gas) | C++14 | 57 ms | 52132 KB |
#include<cstdio> #include<vector> #include<string.h> #include<algorithm> #include<queue> using namespace std; typedef pair<long long, long long> pi; typedef pair<pair<long long, long long>, long long> ppi; long long p[2501]; long long dist[2501][2501]; vector<pi> v[2501]; priority_queue<ppi , vector<ppi>, greater<ppi> > pq; int main() { int n, m, a, b, c; scanf("%d %d", &n, &m); for(int i = 1;i <= n;i++) scanf("%lld", &p[i]); for(int i = 0;i < m;i++) { scanf("%d %d %d", &a, &b, &c); v[a].push_back({b, c}); v[b].push_back({a, c}); } //dijkstra //(지금까지돈, 도시, 지금까지최소기름값) pq.push({{0, 1}, p[1]}); memset(dist, -1, sizeof(dist)); while(!pq.empty()) { long long s = pq.top().first.first; long long f = pq.top().first.second; long long t = pq.top().second; pq.pop(); if(dist[f][t] != -1) continue; dist[f][t] = s; if(f == n) { printf("%lld", s); return 0; } for(int i = 0;i < v[f].size();i++) { if(dist[v[f][i].first][min(t, p[v[f][i].first])] != -1) continue; pq.push({{s + t * v[f][i].second, v[f][i].first}, min(t, p[v[f][i].first])}); } } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 44 ms | 49400 KB | Output is correct |
2 | Correct | 45 ms | 49400 KB | Output is correct |
3 | Correct | 43 ms | 49448 KB | Output is correct |
4 | Correct | 42 ms | 49448 KB | Output is correct |
5 | Correct | 42 ms | 49448 KB | Output is correct |
6 | Correct | 42 ms | 49524 KB | Output is correct |
7 | Correct | 43 ms | 49560 KB | Output is correct |
8 | Correct | 46 ms | 49620 KB | Output is correct |
9 | Correct | 43 ms | 49620 KB | Output is correct |
10 | Correct | 43 ms | 49620 KB | Output is correct |
11 | Correct | 45 ms | 49620 KB | Output is correct |
12 | Correct | 42 ms | 49620 KB | Output is correct |
13 | Correct | 45 ms | 49620 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 44 ms | 49780 KB | Output is correct |
2 | Correct | 47 ms | 49868 KB | Output is correct |
3 | Correct | 45 ms | 49936 KB | Output is correct |
4 | Correct | 44 ms | 50104 KB | Output is correct |
5 | Correct | 44 ms | 50104 KB | Output is correct |
6 | Correct | 44 ms | 50108 KB | Output is correct |
7 | Correct | 44 ms | 50156 KB | Output is correct |
8 | Correct | 45 ms | 50208 KB | Output is correct |
9 | Correct | 48 ms | 50276 KB | Output is correct |
10 | Correct | 44 ms | 50328 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 47 ms | 50328 KB | Output is correct |
2 | Correct | 46 ms | 50536 KB | Output is correct |
3 | Correct | 46 ms | 50688 KB | Output is correct |
4 | Correct | 47 ms | 50700 KB | Output is correct |
5 | Correct | 45 ms | 50736 KB | Output is correct |
6 | Correct | 47 ms | 50828 KB | Output is correct |
7 | Correct | 47 ms | 50892 KB | Output is correct |
8 | Correct | 48 ms | 50948 KB | Output is correct |
9 | Correct | 47 ms | 51012 KB | Output is correct |
10 | Correct | 47 ms | 51060 KB | Output is correct |
11 | Correct | 48 ms | 51112 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 44 ms | 49400 KB | Output is correct |
2 | Correct | 45 ms | 49400 KB | Output is correct |
3 | Correct | 43 ms | 49448 KB | Output is correct |
4 | Correct | 42 ms | 49448 KB | Output is correct |
5 | Correct | 42 ms | 49448 KB | Output is correct |
6 | Correct | 42 ms | 49524 KB | Output is correct |
7 | Correct | 43 ms | 49560 KB | Output is correct |
8 | Correct | 46 ms | 49620 KB | Output is correct |
9 | Correct | 43 ms | 49620 KB | Output is correct |
10 | Correct | 43 ms | 49620 KB | Output is correct |
11 | Correct | 45 ms | 49620 KB | Output is correct |
12 | Correct | 42 ms | 49620 KB | Output is correct |
13 | Correct | 45 ms | 49620 KB | Output is correct |
14 | Correct | 43 ms | 51112 KB | Output is correct |
15 | Correct | 42 ms | 51112 KB | Output is correct |
16 | Correct | 43 ms | 51112 KB | Output is correct |
17 | Correct | 44 ms | 51112 KB | Output is correct |
18 | Correct | 44 ms | 51220 KB | Output is correct |
19 | Correct | 44 ms | 51220 KB | Output is correct |
20 | Correct | 44 ms | 51220 KB | Output is correct |
21 | Correct | 44 ms | 51220 KB | Output is correct |
22 | Correct | 42 ms | 51220 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 44 ms | 49400 KB | Output is correct |
2 | Correct | 45 ms | 49400 KB | Output is correct |
3 | Correct | 43 ms | 49448 KB | Output is correct |
4 | Correct | 42 ms | 49448 KB | Output is correct |
5 | Correct | 42 ms | 49448 KB | Output is correct |
6 | Correct | 42 ms | 49524 KB | Output is correct |
7 | Correct | 43 ms | 49560 KB | Output is correct |
8 | Correct | 46 ms | 49620 KB | Output is correct |
9 | Correct | 43 ms | 49620 KB | Output is correct |
10 | Correct | 43 ms | 49620 KB | Output is correct |
11 | Correct | 45 ms | 49620 KB | Output is correct |
12 | Correct | 42 ms | 49620 KB | Output is correct |
13 | Correct | 45 ms | 49620 KB | Output is correct |
14 | Correct | 44 ms | 49780 KB | Output is correct |
15 | Correct | 47 ms | 49868 KB | Output is correct |
16 | Correct | 45 ms | 49936 KB | Output is correct |
17 | Correct | 44 ms | 50104 KB | Output is correct |
18 | Correct | 44 ms | 50104 KB | Output is correct |
19 | Correct | 44 ms | 50108 KB | Output is correct |
20 | Correct | 44 ms | 50156 KB | Output is correct |
21 | Correct | 45 ms | 50208 KB | Output is correct |
22 | Correct | 48 ms | 50276 KB | Output is correct |
23 | Correct | 44 ms | 50328 KB | Output is correct |
24 | Correct | 47 ms | 50328 KB | Output is correct |
25 | Correct | 46 ms | 50536 KB | Output is correct |
26 | Correct | 46 ms | 50688 KB | Output is correct |
27 | Correct | 47 ms | 50700 KB | Output is correct |
28 | Correct | 45 ms | 50736 KB | Output is correct |
29 | Correct | 47 ms | 50828 KB | Output is correct |
30 | Correct | 47 ms | 50892 KB | Output is correct |
31 | Correct | 48 ms | 50948 KB | Output is correct |
32 | Correct | 47 ms | 51012 KB | Output is correct |
33 | Correct | 47 ms | 51060 KB | Output is correct |
34 | Correct | 48 ms | 51112 KB | Output is correct |
35 | Correct | 43 ms | 51112 KB | Output is correct |
36 | Correct | 42 ms | 51112 KB | Output is correct |
37 | Correct | 43 ms | 51112 KB | Output is correct |
38 | Correct | 44 ms | 51112 KB | Output is correct |
39 | Correct | 44 ms | 51220 KB | Output is correct |
40 | Correct | 44 ms | 51220 KB | Output is correct |
41 | Correct | 44 ms | 51220 KB | Output is correct |
42 | Correct | 44 ms | 51220 KB | Output is correct |
43 | Correct | 42 ms | 51220 KB | Output is correct |
44 | Correct | 46 ms | 51220 KB | Output is correct |
45 | Correct | 47 ms | 51304 KB | Output is correct |
46 | Correct | 47 ms | 51388 KB | Output is correct |
47 | Correct | 57 ms | 51800 KB | Output is correct |
48 | Correct | 48 ms | 51800 KB | Output is correct |
49 | Correct | 49 ms | 52052 KB | Output is correct |
50 | Correct | 46 ms | 52052 KB | Output is correct |
51 | Correct | 56 ms | 52132 KB | Output is correct |
52 | Correct | 46 ms | 52132 KB | Output is correct |