Submission #221153

# Submission time Handle Problem Language Result Execution time Memory
221153 2020-04-09T15:33:34 Z joseacaz Roller Coaster Railroad (IOI16_railroad) C++17
34 / 100
73 ms 8576 KB
#include "railroad.h"
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;

const int MAXN = 16;
const ll INF = (1LL << 62LL);
ll DP[(1 << MAXN)][MAXN];

ll plan_roller_coaster(vi s, vi t)
{
    int N = s.size();
    if(N > 16)
        return 0;

    for(int m = (1 << N) - 1; m >= 0; m--)
    {
        for(int i = 0; i < N; i++)
        {
            if(m == (1 << N) - 1)
            {
                DP[m][i] = 0;
                continue;
            }
            DP[m][i] = INF;
            if(!(m & (1 << i)))
                continue;
            for(int j = 0; j < N; j++)
            {
                if(m & (1 << j))
                    continue;
                DP[m][i] = min(DP[m][i], DP[m | (1 << j)][j] + max(t[i] - s[j], 0));
            }
        }
    }
    ll ans = INF;
    for(int i = 0; i < N; i++)
        ans = min(ans, DP[(1 << i)][i]);
    return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB n = 2
2 Correct 5 ms 256 KB n = 2
3 Correct 5 ms 384 KB n = 2
4 Correct 5 ms 384 KB n = 2
5 Correct 5 ms 256 KB n = 2
6 Correct 4 ms 384 KB n = 2
7 Correct 5 ms 384 KB n = 3
8 Correct 5 ms 384 KB n = 3
9 Correct 5 ms 384 KB n = 3
10 Correct 5 ms 384 KB n = 8
11 Correct 5 ms 384 KB n = 8
12 Correct 5 ms 384 KB n = 8
13 Correct 5 ms 384 KB n = 8
14 Correct 5 ms 384 KB n = 8
15 Correct 5 ms 384 KB n = 8
16 Correct 5 ms 384 KB n = 8
17 Correct 5 ms 384 KB n = 8
18 Correct 5 ms 384 KB n = 8
19 Correct 4 ms 384 KB n = 3
20 Correct 5 ms 384 KB n = 7
21 Correct 5 ms 384 KB n = 8
22 Correct 5 ms 384 KB n = 8
23 Correct 5 ms 384 KB n = 8
24 Correct 5 ms 512 KB n = 8
25 Correct 5 ms 384 KB n = 8
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB n = 2
2 Correct 5 ms 256 KB n = 2
3 Correct 5 ms 384 KB n = 2
4 Correct 5 ms 384 KB n = 2
5 Correct 5 ms 256 KB n = 2
6 Correct 4 ms 384 KB n = 2
7 Correct 5 ms 384 KB n = 3
8 Correct 5 ms 384 KB n = 3
9 Correct 5 ms 384 KB n = 3
10 Correct 5 ms 384 KB n = 8
11 Correct 5 ms 384 KB n = 8
12 Correct 5 ms 384 KB n = 8
13 Correct 5 ms 384 KB n = 8
14 Correct 5 ms 384 KB n = 8
15 Correct 5 ms 384 KB n = 8
16 Correct 5 ms 384 KB n = 8
17 Correct 5 ms 384 KB n = 8
18 Correct 5 ms 384 KB n = 8
19 Correct 4 ms 384 KB n = 3
20 Correct 5 ms 384 KB n = 7
21 Correct 5 ms 384 KB n = 8
22 Correct 5 ms 384 KB n = 8
23 Correct 5 ms 384 KB n = 8
24 Correct 5 ms 512 KB n = 8
25 Correct 5 ms 384 KB n = 8
26 Correct 5 ms 384 KB n = 8
27 Correct 5 ms 384 KB n = 8
28 Correct 5 ms 384 KB n = 8
29 Correct 38 ms 8568 KB n = 16
30 Correct 38 ms 8568 KB n = 16
31 Correct 38 ms 8568 KB n = 16
32 Correct 38 ms 8568 KB n = 16
33 Correct 40 ms 8568 KB n = 16
34 Correct 39 ms 8568 KB n = 16
35 Correct 40 ms 8568 KB n = 16
36 Correct 20 ms 4480 KB n = 15
37 Correct 4 ms 384 KB n = 8
38 Correct 38 ms 8568 KB n = 16
39 Correct 38 ms 8440 KB n = 16
40 Correct 5 ms 384 KB n = 9
41 Correct 45 ms 8568 KB n = 16
42 Correct 38 ms 8568 KB n = 16
43 Correct 38 ms 8568 KB n = 16
44 Correct 5 ms 384 KB n = 9
45 Correct 21 ms 4480 KB n = 15
46 Correct 40 ms 8568 KB n = 16
47 Correct 39 ms 8568 KB n = 16
48 Correct 39 ms 8576 KB n = 16
# Verdict Execution time Memory Grader output
1 Correct 73 ms 7416 KB n = 199999
2 Incorrect 73 ms 7328 KB answer is not correct: 0 instead of 1
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB n = 2
2 Correct 5 ms 256 KB n = 2
3 Correct 5 ms 384 KB n = 2
4 Correct 5 ms 384 KB n = 2
5 Correct 5 ms 256 KB n = 2
6 Correct 4 ms 384 KB n = 2
7 Correct 5 ms 384 KB n = 3
8 Correct 5 ms 384 KB n = 3
9 Correct 5 ms 384 KB n = 3
10 Correct 5 ms 384 KB n = 8
11 Correct 5 ms 384 KB n = 8
12 Correct 5 ms 384 KB n = 8
13 Correct 5 ms 384 KB n = 8
14 Correct 5 ms 384 KB n = 8
15 Correct 5 ms 384 KB n = 8
16 Correct 5 ms 384 KB n = 8
17 Correct 5 ms 384 KB n = 8
18 Correct 5 ms 384 KB n = 8
19 Correct 4 ms 384 KB n = 3
20 Correct 5 ms 384 KB n = 7
21 Correct 5 ms 384 KB n = 8
22 Correct 5 ms 384 KB n = 8
23 Correct 5 ms 384 KB n = 8
24 Correct 5 ms 512 KB n = 8
25 Correct 5 ms 384 KB n = 8
26 Correct 5 ms 384 KB n = 8
27 Correct 5 ms 384 KB n = 8
28 Correct 5 ms 384 KB n = 8
29 Correct 38 ms 8568 KB n = 16
30 Correct 38 ms 8568 KB n = 16
31 Correct 38 ms 8568 KB n = 16
32 Correct 38 ms 8568 KB n = 16
33 Correct 40 ms 8568 KB n = 16
34 Correct 39 ms 8568 KB n = 16
35 Correct 40 ms 8568 KB n = 16
36 Correct 20 ms 4480 KB n = 15
37 Correct 4 ms 384 KB n = 8
38 Correct 38 ms 8568 KB n = 16
39 Correct 38 ms 8440 KB n = 16
40 Correct 5 ms 384 KB n = 9
41 Correct 45 ms 8568 KB n = 16
42 Correct 38 ms 8568 KB n = 16
43 Correct 38 ms 8568 KB n = 16
44 Correct 5 ms 384 KB n = 9
45 Correct 21 ms 4480 KB n = 15
46 Correct 40 ms 8568 KB n = 16
47 Correct 39 ms 8568 KB n = 16
48 Correct 39 ms 8576 KB n = 16
49 Correct 73 ms 7416 KB n = 199999
50 Incorrect 73 ms 7328 KB answer is not correct: 0 instead of 1
51 Halted 0 ms 0 KB -