# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
57063 | 2018-07-13T17:43:17 Z | dennisstar | None (KOI16_gas) | C++11 | 1952 ms | 27440 KB |
#include <bits/stdc++.h> #define mkp(a,b) make_pair(a,b) typedef long long LL; using namespace std; int N,M; int P[2510]; int dist[2510][2510]; long long Dp[2510]; vector<int> R[2510], D[2510]; int arr[2510]; bool cmp(int a, int b){return P[a]>P[b];} priority_queue< pair<int,int>, vector< pair<int,int> >, greater< pair<int,int> > > PQ; int chk[2510]; void djk(int lev) { memset(chk, 0, sizeof(chk)); while(!PQ.empty()) PQ.pop(); PQ.push(mkp(0,lev)); int lv, i, ds; while(!PQ.empty()) { ds=PQ.top().first; lv=PQ.top().second; PQ.pop(); if (chk[lv]) continue; dist[lev][lv]=ds; chk[lv]=1; for (i=0; i<R[lv].size(); i++) { if(chk[R[lv][i]]) continue; PQ.push(mkp(ds+D[lv][i],R[lv][i])); } } } int main() { scanf("%d %d", &N, &M); int i, j, k, x, y; for (i=1; i<=N; i++) scanf("%d",&P[i]); for (i=0; i<M; i++) { scanf("%d %d %d", &x, &y, &j); R[x].push_back(y); R[y].push_back(x); D[x].push_back(j); D[y].push_back(j); } for (i=1; i<=N; i++) arr[i]=i; for (i=1; i<=N; i++) djk(i); sort(arr+2,arr+N,cmp); for (j=2; P[arr[j]]>=P[1]&&j<N; ) j++; for (i=j; i<=N; i++) { Dp[arr[i]]=(LL)P[1]*(LL)dist[1][arr[i]]; for (k=j; k<i; k++) { Dp[arr[i]]=std::min(Dp[arr[i]], Dp[arr[k]]+(LL)P[arr[k]]*dist[arr[k]][arr[i]]); } } printf("%lld", Dp[N]); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 484 KB | Output is correct |
2 | Correct | 1 ms | 616 KB | Output is correct |
3 | Correct | 0 ms | 680 KB | Output is correct |
4 | Correct | 3 ms | 680 KB | Output is correct |
5 | Correct | 4 ms | 720 KB | Output is correct |
6 | Correct | 4 ms | 720 KB | Output is correct |
7 | Correct | 3 ms | 720 KB | Output is correct |
8 | Correct | 3 ms | 720 KB | Output is correct |
9 | Correct | 3 ms | 720 KB | Output is correct |
10 | Correct | 4 ms | 720 KB | Output is correct |
11 | Correct | 3 ms | 720 KB | Output is correct |
12 | Correct | 3 ms | 720 KB | Output is correct |
13 | Correct | 3 ms | 720 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 258 ms | 25468 KB | Output is correct |
2 | Correct | 361 ms | 25520 KB | Output is correct |
3 | Correct | 317 ms | 25564 KB | Output is correct |
4 | Correct | 320 ms | 25868 KB | Output is correct |
5 | Correct | 259 ms | 25868 KB | Output is correct |
6 | Correct | 251 ms | 25868 KB | Output is correct |
7 | Correct | 260 ms | 26004 KB | Output is correct |
8 | Correct | 290 ms | 26080 KB | Output is correct |
9 | Correct | 231 ms | 26080 KB | Output is correct |
10 | Correct | 221 ms | 26080 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 244 ms | 26080 KB | Output is correct |
2 | Correct | 1868 ms | 26220 KB | Output is correct |
3 | Correct | 1778 ms | 26296 KB | Output is correct |
4 | Correct | 1722 ms | 26404 KB | Output is correct |
5 | Correct | 1760 ms | 26404 KB | Output is correct |
6 | Correct | 1824 ms | 26448 KB | Output is correct |
7 | Correct | 1952 ms | 26448 KB | Output is correct |
8 | Correct | 1769 ms | 26628 KB | Output is correct |
9 | Correct | 1367 ms | 26628 KB | Output is correct |
10 | Correct | 1384 ms | 26792 KB | Output is correct |
11 | Correct | 1435 ms | 26792 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 484 KB | Output is correct |
2 | Correct | 1 ms | 616 KB | Output is correct |
3 | Correct | 0 ms | 680 KB | Output is correct |
4 | Correct | 3 ms | 680 KB | Output is correct |
5 | Correct | 4 ms | 720 KB | Output is correct |
6 | Correct | 4 ms | 720 KB | Output is correct |
7 | Correct | 3 ms | 720 KB | Output is correct |
8 | Correct | 3 ms | 720 KB | Output is correct |
9 | Correct | 3 ms | 720 KB | Output is correct |
10 | Correct | 4 ms | 720 KB | Output is correct |
11 | Correct | 3 ms | 720 KB | Output is correct |
12 | Correct | 3 ms | 720 KB | Output is correct |
13 | Correct | 3 ms | 720 KB | Output is correct |
14 | Correct | 22 ms | 26792 KB | Output is correct |
15 | Correct | 21 ms | 26792 KB | Output is correct |
16 | Correct | 19 ms | 26792 KB | Output is correct |
17 | Correct | 175 ms | 26792 KB | Output is correct |
18 | Correct | 156 ms | 26792 KB | Output is correct |
19 | Correct | 49 ms | 26792 KB | Output is correct |
20 | Correct | 51 ms | 26792 KB | Output is correct |
21 | Correct | 50 ms | 26792 KB | Output is correct |
22 | Correct | 53 ms | 26792 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 484 KB | Output is correct |
2 | Correct | 1 ms | 616 KB | Output is correct |
3 | Correct | 0 ms | 680 KB | Output is correct |
4 | Correct | 3 ms | 680 KB | Output is correct |
5 | Correct | 4 ms | 720 KB | Output is correct |
6 | Correct | 4 ms | 720 KB | Output is correct |
7 | Correct | 3 ms | 720 KB | Output is correct |
8 | Correct | 3 ms | 720 KB | Output is correct |
9 | Correct | 3 ms | 720 KB | Output is correct |
10 | Correct | 4 ms | 720 KB | Output is correct |
11 | Correct | 3 ms | 720 KB | Output is correct |
12 | Correct | 3 ms | 720 KB | Output is correct |
13 | Correct | 3 ms | 720 KB | Output is correct |
14 | Correct | 258 ms | 25468 KB | Output is correct |
15 | Correct | 361 ms | 25520 KB | Output is correct |
16 | Correct | 317 ms | 25564 KB | Output is correct |
17 | Correct | 320 ms | 25868 KB | Output is correct |
18 | Correct | 259 ms | 25868 KB | Output is correct |
19 | Correct | 251 ms | 25868 KB | Output is correct |
20 | Correct | 260 ms | 26004 KB | Output is correct |
21 | Correct | 290 ms | 26080 KB | Output is correct |
22 | Correct | 231 ms | 26080 KB | Output is correct |
23 | Correct | 221 ms | 26080 KB | Output is correct |
24 | Correct | 244 ms | 26080 KB | Output is correct |
25 | Correct | 1868 ms | 26220 KB | Output is correct |
26 | Correct | 1778 ms | 26296 KB | Output is correct |
27 | Correct | 1722 ms | 26404 KB | Output is correct |
28 | Correct | 1760 ms | 26404 KB | Output is correct |
29 | Correct | 1824 ms | 26448 KB | Output is correct |
30 | Correct | 1952 ms | 26448 KB | Output is correct |
31 | Correct | 1769 ms | 26628 KB | Output is correct |
32 | Correct | 1367 ms | 26628 KB | Output is correct |
33 | Correct | 1384 ms | 26792 KB | Output is correct |
34 | Correct | 1435 ms | 26792 KB | Output is correct |
35 | Correct | 22 ms | 26792 KB | Output is correct |
36 | Correct | 21 ms | 26792 KB | Output is correct |
37 | Correct | 19 ms | 26792 KB | Output is correct |
38 | Correct | 175 ms | 26792 KB | Output is correct |
39 | Correct | 156 ms | 26792 KB | Output is correct |
40 | Correct | 49 ms | 26792 KB | Output is correct |
41 | Correct | 51 ms | 26792 KB | Output is correct |
42 | Correct | 50 ms | 26792 KB | Output is correct |
43 | Correct | 53 ms | 26792 KB | Output is correct |
44 | Correct | 611 ms | 26872 KB | Output is correct |
45 | Correct | 643 ms | 26936 KB | Output is correct |
46 | Correct | 749 ms | 26936 KB | Output is correct |
47 | Correct | 1816 ms | 27184 KB | Output is correct |
48 | Correct | 1762 ms | 27320 KB | Output is correct |
49 | Correct | 1455 ms | 27388 KB | Output is correct |
50 | Correct | 1520 ms | 27388 KB | Output is correct |
51 | Correct | 1504 ms | 27388 KB | Output is correct |
52 | Correct | 1494 ms | 27440 KB | Output is correct |