Submission #135412

# Submission time Handle Problem Language Result Execution time Memory
135412 2019-07-24T05:04:34 Z antimirage Roller Coaster Railroad (IOI16_railroad) C++14
34 / 100
124 ms 44228 KB
#include "railroad.h"
#include <bits/stdc++.h>

#define fr first
#define sc second
#define mk make_pair
#define pb push_back
#define all(s) s.begin(), s.end()

using namespace std;

int n;
long long dp[1 << 17][18], ans = 1e18;

long long plan_roller_coaster(vector <int> a, vector<int> b) {
	n = a.size();
	memset(dp, 0x3f3f3f3f, sizeof(dp));
	
	for (int i = 0; i < n; i++) {
		dp[1 << i][i] = 0;
	}
	
	for (int mask = 1; mask < (1 << n); mask++) {
		for (int last = 0; last < n; last++) {
			if ((mask>>last&1) == 0) continue;
			for (int j = 0; j < n; j++) {
				if (mask>>j&1) continue;
				dp[mask + (1 << j)][j] = min( dp[mask + (1 << j)][j], dp[mask][last] + max(0, b[last] - a[j]) );
			}
		}
	}
	for (int i = 0; i < n; i++)
		ans = min(ans, dp[(1 << n) - 1][i]);
	return ans;
}

# Verdict Execution time Memory Grader output
1 Correct 18 ms 18808 KB n = 2
2 Correct 21 ms 18808 KB n = 2
3 Correct 20 ms 18808 KB n = 2
4 Correct 19 ms 18808 KB n = 2
5 Correct 17 ms 18808 KB n = 2
6 Correct 17 ms 18808 KB n = 2
7 Correct 17 ms 18808 KB n = 3
8 Correct 17 ms 18808 KB n = 3
9 Correct 17 ms 18808 KB n = 3
10 Correct 17 ms 18808 KB n = 8
11 Correct 17 ms 18808 KB n = 8
12 Correct 17 ms 18712 KB n = 8
13 Correct 17 ms 18808 KB n = 8
14 Correct 17 ms 18808 KB n = 8
15 Correct 17 ms 18808 KB n = 8
16 Correct 20 ms 18808 KB n = 8
17 Correct 17 ms 18808 KB n = 8
18 Correct 17 ms 18808 KB n = 8
19 Correct 17 ms 18812 KB n = 3
20 Correct 17 ms 18808 KB n = 7
21 Correct 17 ms 18780 KB n = 8
22 Correct 22 ms 18808 KB n = 8
23 Correct 21 ms 18808 KB n = 8
24 Correct 17 ms 18808 KB n = 8
25 Correct 19 ms 18808 KB n = 8
# Verdict Execution time Memory Grader output
1 Correct 18 ms 18808 KB n = 2
2 Correct 21 ms 18808 KB n = 2
3 Correct 20 ms 18808 KB n = 2
4 Correct 19 ms 18808 KB n = 2
5 Correct 17 ms 18808 KB n = 2
6 Correct 17 ms 18808 KB n = 2
7 Correct 17 ms 18808 KB n = 3
8 Correct 17 ms 18808 KB n = 3
9 Correct 17 ms 18808 KB n = 3
10 Correct 17 ms 18808 KB n = 8
11 Correct 17 ms 18808 KB n = 8
12 Correct 17 ms 18712 KB n = 8
13 Correct 17 ms 18808 KB n = 8
14 Correct 17 ms 18808 KB n = 8
15 Correct 17 ms 18808 KB n = 8
16 Correct 20 ms 18808 KB n = 8
17 Correct 17 ms 18808 KB n = 8
18 Correct 17 ms 18808 KB n = 8
19 Correct 17 ms 18812 KB n = 3
20 Correct 17 ms 18808 KB n = 7
21 Correct 17 ms 18780 KB n = 8
22 Correct 22 ms 18808 KB n = 8
23 Correct 21 ms 18808 KB n = 8
24 Correct 17 ms 18808 KB n = 8
25 Correct 19 ms 18808 KB n = 8
26 Correct 20 ms 18808 KB n = 8
27 Correct 17 ms 18808 KB n = 8
28 Correct 17 ms 18732 KB n = 8
29 Correct 62 ms 18808 KB n = 16
30 Correct 54 ms 18796 KB n = 16
31 Correct 55 ms 18780 KB n = 16
32 Correct 54 ms 18860 KB n = 16
33 Correct 54 ms 18936 KB n = 16
34 Correct 54 ms 18808 KB n = 16
35 Correct 54 ms 18808 KB n = 16
36 Correct 34 ms 18808 KB n = 15
37 Correct 17 ms 18804 KB n = 8
38 Correct 54 ms 18936 KB n = 16
39 Correct 54 ms 18808 KB n = 16
40 Correct 17 ms 18808 KB n = 9
41 Correct 54 ms 18808 KB n = 16
42 Correct 54 ms 18808 KB n = 16
43 Correct 54 ms 18808 KB n = 16
44 Correct 17 ms 18808 KB n = 9
45 Correct 33 ms 18936 KB n = 15
46 Correct 54 ms 18808 KB n = 16
47 Correct 54 ms 18936 KB n = 16
48 Correct 54 ms 18780 KB n = 16
# Verdict Execution time Memory Grader output
1 Runtime error 124 ms 44228 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 18 ms 18808 KB n = 2
2 Correct 21 ms 18808 KB n = 2
3 Correct 20 ms 18808 KB n = 2
4 Correct 19 ms 18808 KB n = 2
5 Correct 17 ms 18808 KB n = 2
6 Correct 17 ms 18808 KB n = 2
7 Correct 17 ms 18808 KB n = 3
8 Correct 17 ms 18808 KB n = 3
9 Correct 17 ms 18808 KB n = 3
10 Correct 17 ms 18808 KB n = 8
11 Correct 17 ms 18808 KB n = 8
12 Correct 17 ms 18712 KB n = 8
13 Correct 17 ms 18808 KB n = 8
14 Correct 17 ms 18808 KB n = 8
15 Correct 17 ms 18808 KB n = 8
16 Correct 20 ms 18808 KB n = 8
17 Correct 17 ms 18808 KB n = 8
18 Correct 17 ms 18808 KB n = 8
19 Correct 17 ms 18812 KB n = 3
20 Correct 17 ms 18808 KB n = 7
21 Correct 17 ms 18780 KB n = 8
22 Correct 22 ms 18808 KB n = 8
23 Correct 21 ms 18808 KB n = 8
24 Correct 17 ms 18808 KB n = 8
25 Correct 19 ms 18808 KB n = 8
26 Correct 20 ms 18808 KB n = 8
27 Correct 17 ms 18808 KB n = 8
28 Correct 17 ms 18732 KB n = 8
29 Correct 62 ms 18808 KB n = 16
30 Correct 54 ms 18796 KB n = 16
31 Correct 55 ms 18780 KB n = 16
32 Correct 54 ms 18860 KB n = 16
33 Correct 54 ms 18936 KB n = 16
34 Correct 54 ms 18808 KB n = 16
35 Correct 54 ms 18808 KB n = 16
36 Correct 34 ms 18808 KB n = 15
37 Correct 17 ms 18804 KB n = 8
38 Correct 54 ms 18936 KB n = 16
39 Correct 54 ms 18808 KB n = 16
40 Correct 17 ms 18808 KB n = 9
41 Correct 54 ms 18808 KB n = 16
42 Correct 54 ms 18808 KB n = 16
43 Correct 54 ms 18808 KB n = 16
44 Correct 17 ms 18808 KB n = 9
45 Correct 33 ms 18936 KB n = 15
46 Correct 54 ms 18808 KB n = 16
47 Correct 54 ms 18936 KB n = 16
48 Correct 54 ms 18780 KB n = 16
49 Runtime error 124 ms 44228 KB Execution killed with signal 11 (could be triggered by violating memory limits)
50 Halted 0 ms 0 KB -