#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18;
long long plan_roller_coaster(vector<int> s, vector<int> t){
int n = (int)s.size();
vector<int> next(n);
for(int i = 0; i < n; ++i)
next[i] = i;
// next vector is sorted
long long answer = INF;
do{
long long sum = 0;
for(int i = 1; i < n; ++i)
sum += max(0, t[next[i-1]]-s[next[i]]);
answer = min(answer, sum);
}while(next_permutation(next.begin(), next.end()));
return answer;
}
// int main(){
// long long jogap = plan_roller_coaster({1, 4, 5, 6}, {7, 3, 8, 6});
// printf("%lld", jogap);
// }
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
n = 2 |
2 |
Correct |
0 ms |
504 KB |
n = 2 |
3 |
Correct |
0 ms |
348 KB |
n = 2 |
4 |
Correct |
1 ms |
348 KB |
n = 2 |
5 |
Correct |
0 ms |
348 KB |
n = 2 |
6 |
Correct |
0 ms |
348 KB |
n = 2 |
7 |
Correct |
0 ms |
348 KB |
n = 3 |
8 |
Correct |
0 ms |
348 KB |
n = 3 |
9 |
Correct |
0 ms |
348 KB |
n = 3 |
10 |
Correct |
1 ms |
348 KB |
n = 8 |
11 |
Correct |
1 ms |
348 KB |
n = 8 |
12 |
Correct |
1 ms |
348 KB |
n = 8 |
13 |
Correct |
1 ms |
348 KB |
n = 8 |
14 |
Correct |
1 ms |
348 KB |
n = 8 |
15 |
Correct |
1 ms |
348 KB |
n = 8 |
16 |
Correct |
1 ms |
348 KB |
n = 8 |
17 |
Correct |
1 ms |
436 KB |
n = 8 |
18 |
Correct |
1 ms |
344 KB |
n = 8 |
19 |
Correct |
1 ms |
348 KB |
n = 3 |
20 |
Correct |
0 ms |
348 KB |
n = 7 |
21 |
Correct |
1 ms |
348 KB |
n = 8 |
22 |
Correct |
1 ms |
348 KB |
n = 8 |
23 |
Correct |
1 ms |
348 KB |
n = 8 |
24 |
Correct |
1 ms |
348 KB |
n = 8 |
25 |
Correct |
1 ms |
348 KB |
n = 8 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
n = 2 |
2 |
Correct |
0 ms |
504 KB |
n = 2 |
3 |
Correct |
0 ms |
348 KB |
n = 2 |
4 |
Correct |
1 ms |
348 KB |
n = 2 |
5 |
Correct |
0 ms |
348 KB |
n = 2 |
6 |
Correct |
0 ms |
348 KB |
n = 2 |
7 |
Correct |
0 ms |
348 KB |
n = 3 |
8 |
Correct |
0 ms |
348 KB |
n = 3 |
9 |
Correct |
0 ms |
348 KB |
n = 3 |
10 |
Correct |
1 ms |
348 KB |
n = 8 |
11 |
Correct |
1 ms |
348 KB |
n = 8 |
12 |
Correct |
1 ms |
348 KB |
n = 8 |
13 |
Correct |
1 ms |
348 KB |
n = 8 |
14 |
Correct |
1 ms |
348 KB |
n = 8 |
15 |
Correct |
1 ms |
348 KB |
n = 8 |
16 |
Correct |
1 ms |
348 KB |
n = 8 |
17 |
Correct |
1 ms |
436 KB |
n = 8 |
18 |
Correct |
1 ms |
344 KB |
n = 8 |
19 |
Correct |
1 ms |
348 KB |
n = 3 |
20 |
Correct |
0 ms |
348 KB |
n = 7 |
21 |
Correct |
1 ms |
348 KB |
n = 8 |
22 |
Correct |
1 ms |
348 KB |
n = 8 |
23 |
Correct |
1 ms |
348 KB |
n = 8 |
24 |
Correct |
1 ms |
348 KB |
n = 8 |
25 |
Correct |
1 ms |
348 KB |
n = 8 |
26 |
Correct |
1 ms |
344 KB |
n = 8 |
27 |
Correct |
1 ms |
348 KB |
n = 8 |
28 |
Correct |
1 ms |
348 KB |
n = 8 |
29 |
Execution timed out |
2052 ms |
348 KB |
Time limit exceeded |
30 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2033 ms |
8028 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
n = 2 |
2 |
Correct |
0 ms |
504 KB |
n = 2 |
3 |
Correct |
0 ms |
348 KB |
n = 2 |
4 |
Correct |
1 ms |
348 KB |
n = 2 |
5 |
Correct |
0 ms |
348 KB |
n = 2 |
6 |
Correct |
0 ms |
348 KB |
n = 2 |
7 |
Correct |
0 ms |
348 KB |
n = 3 |
8 |
Correct |
0 ms |
348 KB |
n = 3 |
9 |
Correct |
0 ms |
348 KB |
n = 3 |
10 |
Correct |
1 ms |
348 KB |
n = 8 |
11 |
Correct |
1 ms |
348 KB |
n = 8 |
12 |
Correct |
1 ms |
348 KB |
n = 8 |
13 |
Correct |
1 ms |
348 KB |
n = 8 |
14 |
Correct |
1 ms |
348 KB |
n = 8 |
15 |
Correct |
1 ms |
348 KB |
n = 8 |
16 |
Correct |
1 ms |
348 KB |
n = 8 |
17 |
Correct |
1 ms |
436 KB |
n = 8 |
18 |
Correct |
1 ms |
344 KB |
n = 8 |
19 |
Correct |
1 ms |
348 KB |
n = 3 |
20 |
Correct |
0 ms |
348 KB |
n = 7 |
21 |
Correct |
1 ms |
348 KB |
n = 8 |
22 |
Correct |
1 ms |
348 KB |
n = 8 |
23 |
Correct |
1 ms |
348 KB |
n = 8 |
24 |
Correct |
1 ms |
348 KB |
n = 8 |
25 |
Correct |
1 ms |
348 KB |
n = 8 |
26 |
Correct |
1 ms |
344 KB |
n = 8 |
27 |
Correct |
1 ms |
348 KB |
n = 8 |
28 |
Correct |
1 ms |
348 KB |
n = 8 |
29 |
Execution timed out |
2052 ms |
348 KB |
Time limit exceeded |
30 |
Halted |
0 ms |
0 KB |
- |