#include "railroad.h"
#include<bits/stdc++.h>
const int MN=16+1;
const long long inf=1e18;
long long dp[1<<MN][MN];
using namespace std;
long long plan_roller_coaster(vector<int> s, vector<int> t) {
int n = (int) s.size();
long long ans=inf;
for(int i=0;i<(1<<n);i++){
for(int j=0;j<n;j++){
dp[i][j]=inf;
if((i^(1<<j))==0)
{
dp[i][j]=0;
}
for(int k=0;k<n;k++){
if((i&(1<<j)) && (i&(1<<k)) && j!=k){
dp[i][j]=min(dp[i][j],dp[i^(1<<j)][k]+max(0,t[k]-s[j]));
}
}
if(i==((1<<n)-1)){
ans=min(ans,dp[i][j]);
}
}
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
348 KB |
n = 2 |
2 |
Correct |
2 ms |
360 KB |
n = 2 |
3 |
Correct |
2 ms |
476 KB |
n = 2 |
4 |
Correct |
2 ms |
604 KB |
n = 2 |
5 |
Correct |
3 ms |
604 KB |
n = 2 |
6 |
Correct |
2 ms |
604 KB |
n = 2 |
7 |
Correct |
3 ms |
692 KB |
n = 3 |
8 |
Correct |
4 ms |
692 KB |
n = 3 |
9 |
Correct |
2 ms |
692 KB |
n = 3 |
10 |
Correct |
2 ms |
696 KB |
n = 8 |
11 |
Correct |
3 ms |
696 KB |
n = 8 |
12 |
Correct |
3 ms |
828 KB |
n = 8 |
13 |
Correct |
2 ms |
828 KB |
n = 8 |
14 |
Correct |
3 ms |
828 KB |
n = 8 |
15 |
Correct |
2 ms |
828 KB |
n = 8 |
16 |
Correct |
3 ms |
828 KB |
n = 8 |
17 |
Correct |
4 ms |
828 KB |
n = 8 |
18 |
Correct |
3 ms |
828 KB |
n = 8 |
19 |
Correct |
2 ms |
828 KB |
n = 3 |
20 |
Correct |
2 ms |
828 KB |
n = 7 |
21 |
Correct |
3 ms |
828 KB |
n = 8 |
22 |
Correct |
2 ms |
828 KB |
n = 8 |
23 |
Correct |
3 ms |
828 KB |
n = 8 |
24 |
Correct |
3 ms |
828 KB |
n = 8 |
25 |
Correct |
3 ms |
828 KB |
n = 8 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
348 KB |
n = 2 |
2 |
Correct |
2 ms |
360 KB |
n = 2 |
3 |
Correct |
2 ms |
476 KB |
n = 2 |
4 |
Correct |
2 ms |
604 KB |
n = 2 |
5 |
Correct |
3 ms |
604 KB |
n = 2 |
6 |
Correct |
2 ms |
604 KB |
n = 2 |
7 |
Correct |
3 ms |
692 KB |
n = 3 |
8 |
Correct |
4 ms |
692 KB |
n = 3 |
9 |
Correct |
2 ms |
692 KB |
n = 3 |
10 |
Correct |
2 ms |
696 KB |
n = 8 |
11 |
Correct |
3 ms |
696 KB |
n = 8 |
12 |
Correct |
3 ms |
828 KB |
n = 8 |
13 |
Correct |
2 ms |
828 KB |
n = 8 |
14 |
Correct |
3 ms |
828 KB |
n = 8 |
15 |
Correct |
2 ms |
828 KB |
n = 8 |
16 |
Correct |
3 ms |
828 KB |
n = 8 |
17 |
Correct |
4 ms |
828 KB |
n = 8 |
18 |
Correct |
3 ms |
828 KB |
n = 8 |
19 |
Correct |
2 ms |
828 KB |
n = 3 |
20 |
Correct |
2 ms |
828 KB |
n = 7 |
21 |
Correct |
3 ms |
828 KB |
n = 8 |
22 |
Correct |
2 ms |
828 KB |
n = 8 |
23 |
Correct |
3 ms |
828 KB |
n = 8 |
24 |
Correct |
3 ms |
828 KB |
n = 8 |
25 |
Correct |
3 ms |
828 KB |
n = 8 |
26 |
Correct |
3 ms |
828 KB |
n = 8 |
27 |
Correct |
3 ms |
828 KB |
n = 8 |
28 |
Correct |
3 ms |
828 KB |
n = 8 |
29 |
Correct |
77 ms |
9452 KB |
n = 16 |
30 |
Correct |
90 ms |
9504 KB |
n = 16 |
31 |
Correct |
84 ms |
9540 KB |
n = 16 |
32 |
Correct |
80 ms |
9544 KB |
n = 16 |
33 |
Correct |
96 ms |
9552 KB |
n = 16 |
34 |
Correct |
75 ms |
9556 KB |
n = 16 |
35 |
Correct |
80 ms |
9556 KB |
n = 16 |
36 |
Correct |
44 ms |
9556 KB |
n = 15 |
37 |
Correct |
2 ms |
9556 KB |
n = 8 |
38 |
Correct |
77 ms |
9580 KB |
n = 16 |
39 |
Correct |
78 ms |
9580 KB |
n = 16 |
40 |
Correct |
4 ms |
9580 KB |
n = 9 |
41 |
Correct |
77 ms |
9600 KB |
n = 16 |
42 |
Correct |
80 ms |
9668 KB |
n = 16 |
43 |
Correct |
75 ms |
9668 KB |
n = 16 |
44 |
Correct |
3 ms |
9668 KB |
n = 9 |
45 |
Correct |
37 ms |
9668 KB |
n = 15 |
46 |
Correct |
82 ms |
9668 KB |
n = 16 |
47 |
Correct |
77 ms |
9684 KB |
n = 16 |
48 |
Correct |
80 ms |
9684 KB |
n = 16 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
79 ms |
9684 KB |
answer is not correct: 1 instead of 0 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
348 KB |
n = 2 |
2 |
Correct |
2 ms |
360 KB |
n = 2 |
3 |
Correct |
2 ms |
476 KB |
n = 2 |
4 |
Correct |
2 ms |
604 KB |
n = 2 |
5 |
Correct |
3 ms |
604 KB |
n = 2 |
6 |
Correct |
2 ms |
604 KB |
n = 2 |
7 |
Correct |
3 ms |
692 KB |
n = 3 |
8 |
Correct |
4 ms |
692 KB |
n = 3 |
9 |
Correct |
2 ms |
692 KB |
n = 3 |
10 |
Correct |
2 ms |
696 KB |
n = 8 |
11 |
Correct |
3 ms |
696 KB |
n = 8 |
12 |
Correct |
3 ms |
828 KB |
n = 8 |
13 |
Correct |
2 ms |
828 KB |
n = 8 |
14 |
Correct |
3 ms |
828 KB |
n = 8 |
15 |
Correct |
2 ms |
828 KB |
n = 8 |
16 |
Correct |
3 ms |
828 KB |
n = 8 |
17 |
Correct |
4 ms |
828 KB |
n = 8 |
18 |
Correct |
3 ms |
828 KB |
n = 8 |
19 |
Correct |
2 ms |
828 KB |
n = 3 |
20 |
Correct |
2 ms |
828 KB |
n = 7 |
21 |
Correct |
3 ms |
828 KB |
n = 8 |
22 |
Correct |
2 ms |
828 KB |
n = 8 |
23 |
Correct |
3 ms |
828 KB |
n = 8 |
24 |
Correct |
3 ms |
828 KB |
n = 8 |
25 |
Correct |
3 ms |
828 KB |
n = 8 |
26 |
Correct |
3 ms |
828 KB |
n = 8 |
27 |
Correct |
3 ms |
828 KB |
n = 8 |
28 |
Correct |
3 ms |
828 KB |
n = 8 |
29 |
Correct |
77 ms |
9452 KB |
n = 16 |
30 |
Correct |
90 ms |
9504 KB |
n = 16 |
31 |
Correct |
84 ms |
9540 KB |
n = 16 |
32 |
Correct |
80 ms |
9544 KB |
n = 16 |
33 |
Correct |
96 ms |
9552 KB |
n = 16 |
34 |
Correct |
75 ms |
9556 KB |
n = 16 |
35 |
Correct |
80 ms |
9556 KB |
n = 16 |
36 |
Correct |
44 ms |
9556 KB |
n = 15 |
37 |
Correct |
2 ms |
9556 KB |
n = 8 |
38 |
Correct |
77 ms |
9580 KB |
n = 16 |
39 |
Correct |
78 ms |
9580 KB |
n = 16 |
40 |
Correct |
4 ms |
9580 KB |
n = 9 |
41 |
Correct |
77 ms |
9600 KB |
n = 16 |
42 |
Correct |
80 ms |
9668 KB |
n = 16 |
43 |
Correct |
75 ms |
9668 KB |
n = 16 |
44 |
Correct |
3 ms |
9668 KB |
n = 9 |
45 |
Correct |
37 ms |
9668 KB |
n = 15 |
46 |
Correct |
82 ms |
9668 KB |
n = 16 |
47 |
Correct |
77 ms |
9684 KB |
n = 16 |
48 |
Correct |
80 ms |
9684 KB |
n = 16 |
49 |
Incorrect |
79 ms |
9684 KB |
answer is not correct: 1 instead of 0 |
50 |
Halted |
0 ms |
0 KB |
- |