Submission #62390

# Submission time Handle Problem Language Result Execution time Memory
62390 2018-07-28T09:38:34 Z fallingstar Roller Coaster Railroad (IOI16_railroad) C++14
34 / 100
196 ms 11280 KB
#include "railroad.h"

#define long long long

using namespace std;

const int N = 16;
const long INF = 1LL << 60;

int n, vin[N], vout[N + 1];
long f[N + 1][1 << N];
bool vst[N + 1][1 << N];

void Minimize(long &a, long b) { a = min(a, b); }

long DP(int spd, int mask)
{
    if (vst[spd][mask]) return f[spd][mask];
    vst[spd][mask] = true;

    if (__builtin_popcount(mask) == n) return 0;

    f[spd][mask] = INF;

    for (int v = 0; v < n; ++v)
        if (!((mask >> v) & 1))
            Minimize(f[spd][mask], DP(v, mask | (1 << v)) + max(vout[spd] - vin[v], 0));

    return f[spd][mask];
}

long plan_roller_coaster(vector<int> s, vector<int> t) {
    n = (int) s.size();
    for (int i = 0; i < n; ++i)
    {
        vin[i] = s[i];
        vout[i] = t[i];
    }
    vout[n] = 1;
    return DP(n, 0);
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB n = 2
2 Correct 3 ms 472 KB n = 2
3 Correct 2 ms 584 KB n = 2
4 Correct 2 ms 700 KB n = 2
5 Correct 3 ms 808 KB n = 2
6 Correct 2 ms 920 KB n = 2
7 Correct 2 ms 920 KB n = 3
8 Correct 2 ms 920 KB n = 3
9 Correct 3 ms 956 KB n = 3
10 Correct 3 ms 956 KB n = 8
11 Correct 4 ms 956 KB n = 8
12 Correct 4 ms 956 KB n = 8
13 Correct 4 ms 956 KB n = 8
14 Correct 4 ms 956 KB n = 8
15 Correct 3 ms 956 KB n = 8
16 Correct 3 ms 956 KB n = 8
17 Correct 4 ms 956 KB n = 8
18 Correct 3 ms 956 KB n = 8
19 Correct 3 ms 956 KB n = 3
20 Correct 2 ms 956 KB n = 7
21 Correct 2 ms 956 KB n = 8
22 Correct 3 ms 1036 KB n = 8
23 Correct 3 ms 1036 KB n = 8
24 Correct 2 ms 1036 KB n = 8
25 Correct 3 ms 1036 KB n = 8
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB n = 2
2 Correct 3 ms 472 KB n = 2
3 Correct 2 ms 584 KB n = 2
4 Correct 2 ms 700 KB n = 2
5 Correct 3 ms 808 KB n = 2
6 Correct 2 ms 920 KB n = 2
7 Correct 2 ms 920 KB n = 3
8 Correct 2 ms 920 KB n = 3
9 Correct 3 ms 956 KB n = 3
10 Correct 3 ms 956 KB n = 8
11 Correct 4 ms 956 KB n = 8
12 Correct 4 ms 956 KB n = 8
13 Correct 4 ms 956 KB n = 8
14 Correct 4 ms 956 KB n = 8
15 Correct 3 ms 956 KB n = 8
16 Correct 3 ms 956 KB n = 8
17 Correct 4 ms 956 KB n = 8
18 Correct 3 ms 956 KB n = 8
19 Correct 3 ms 956 KB n = 3
20 Correct 2 ms 956 KB n = 7
21 Correct 2 ms 956 KB n = 8
22 Correct 3 ms 1036 KB n = 8
23 Correct 3 ms 1036 KB n = 8
24 Correct 2 ms 1036 KB n = 8
25 Correct 3 ms 1036 KB n = 8
26 Correct 3 ms 1036 KB n = 8
27 Correct 2 ms 1036 KB n = 8
28 Correct 3 ms 1036 KB n = 8
29 Correct 133 ms 8764 KB n = 16
30 Correct 165 ms 8828 KB n = 16
31 Correct 184 ms 8828 KB n = 16
32 Correct 121 ms 8828 KB n = 16
33 Correct 186 ms 8828 KB n = 16
34 Correct 148 ms 8916 KB n = 16
35 Correct 126 ms 8972 KB n = 16
36 Correct 74 ms 8972 KB n = 15
37 Correct 3 ms 8972 KB n = 8
38 Correct 196 ms 8972 KB n = 16
39 Correct 162 ms 8972 KB n = 16
40 Correct 3 ms 8972 KB n = 9
41 Correct 141 ms 8972 KB n = 16
42 Correct 173 ms 8972 KB n = 16
43 Correct 174 ms 9064 KB n = 16
44 Correct 3 ms 9064 KB n = 9
45 Correct 45 ms 9064 KB n = 15
46 Correct 127 ms 9064 KB n = 16
47 Correct 128 ms 9064 KB n = 16
48 Correct 144 ms 9064 KB n = 16
# Verdict Execution time Memory Grader output
1 Runtime error 92 ms 11280 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 2 ms 376 KB n = 2
2 Correct 3 ms 472 KB n = 2
3 Correct 2 ms 584 KB n = 2
4 Correct 2 ms 700 KB n = 2
5 Correct 3 ms 808 KB n = 2
6 Correct 2 ms 920 KB n = 2
7 Correct 2 ms 920 KB n = 3
8 Correct 2 ms 920 KB n = 3
9 Correct 3 ms 956 KB n = 3
10 Correct 3 ms 956 KB n = 8
11 Correct 4 ms 956 KB n = 8
12 Correct 4 ms 956 KB n = 8
13 Correct 4 ms 956 KB n = 8
14 Correct 4 ms 956 KB n = 8
15 Correct 3 ms 956 KB n = 8
16 Correct 3 ms 956 KB n = 8
17 Correct 4 ms 956 KB n = 8
18 Correct 3 ms 956 KB n = 8
19 Correct 3 ms 956 KB n = 3
20 Correct 2 ms 956 KB n = 7
21 Correct 2 ms 956 KB n = 8
22 Correct 3 ms 1036 KB n = 8
23 Correct 3 ms 1036 KB n = 8
24 Correct 2 ms 1036 KB n = 8
25 Correct 3 ms 1036 KB n = 8
26 Correct 3 ms 1036 KB n = 8
27 Correct 2 ms 1036 KB n = 8
28 Correct 3 ms 1036 KB n = 8
29 Correct 133 ms 8764 KB n = 16
30 Correct 165 ms 8828 KB n = 16
31 Correct 184 ms 8828 KB n = 16
32 Correct 121 ms 8828 KB n = 16
33 Correct 186 ms 8828 KB n = 16
34 Correct 148 ms 8916 KB n = 16
35 Correct 126 ms 8972 KB n = 16
36 Correct 74 ms 8972 KB n = 15
37 Correct 3 ms 8972 KB n = 8
38 Correct 196 ms 8972 KB n = 16
39 Correct 162 ms 8972 KB n = 16
40 Correct 3 ms 8972 KB n = 9
41 Correct 141 ms 8972 KB n = 16
42 Correct 173 ms 8972 KB n = 16
43 Correct 174 ms 9064 KB n = 16
44 Correct 3 ms 9064 KB n = 9
45 Correct 45 ms 9064 KB n = 15
46 Correct 127 ms 9064 KB n = 16
47 Correct 128 ms 9064 KB n = 16
48 Correct 144 ms 9064 KB n = 16
49 Runtime error 92 ms 11280 KB Execution killed with signal 11 (could be triggered by violating memory limits)
50 Halted 0 ms 0 KB -