Submission #61221

# Submission time Handle Problem Language Result Execution time Memory
61221 2018-07-25T11:34:38 Z Kubalionzzale Roller Coaster Railroad (IOI16_railroad) C++14
34 / 100
143 ms 42436 KB
#include "railroad.h"

#include <iostream>
#include <algorithm>

long long plan_roller_coaster(std::vector<int> s, std::vector<int> t) {
    int n = (int) s.size();

    long long int dp[100010][20] = { 0 };
    dp[0][0] = 0;

    int val = 1 << n;

    for (int x = 1; x < val; ++x)
    {
        for (int j = 0; j < n; ++j)
        {
            dp[x][j] = 1e15;
        }
    }

    for (int x = 1; x < val; ++x)
    {
        int bitNr = __builtin_popcount(x);

        if (bitNr == 1)
        {
            for (int j = 0; j < n; ++j)
            {
                if (x & (1 << j))
                {
                    dp[x][j] = 0;
                    break;
                }
            }
        }
        else
        {
            for (int j = 0; j < n; ++j)
            {
                if (x & (1 << j))
                {
                    int newNr = x ^ (1 << j);

                    for (int k = 0; k < n; ++k)
                    {
                        if (newNr & (1 << k))
                        {
                            dp[x][j] = std::min(dp[x][j], dp[newNr][k] + std::max(0, t[k] - s[j]));
                        }
                    }
                }
            }
        }
    }
/*
    for (int x = 1; x < val; ++x)
    {
        for (int j = 0; j < n; ++j)
        {
            std::cout << x << " " << j << " " << dp[x][j] << "\n";
        }
    }
*/
    --val;
    long long int ans = 1e15;
    for (int i = 0; i < n; ++i)
    {
        ans = std::min(ans, dp[val][i]);
    }

    return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 15 ms 15992 KB n = 2
2 Correct 17 ms 16104 KB n = 2
3 Correct 15 ms 16204 KB n = 2
4 Correct 15 ms 16372 KB n = 2
5 Correct 16 ms 16372 KB n = 2
6 Correct 16 ms 16372 KB n = 2
7 Correct 16 ms 16372 KB n = 3
8 Correct 18 ms 16372 KB n = 3
9 Correct 15 ms 16372 KB n = 3
10 Correct 15 ms 16372 KB n = 8
11 Correct 18 ms 16372 KB n = 8
12 Correct 19 ms 16372 KB n = 8
13 Correct 18 ms 16372 KB n = 8
14 Correct 18 ms 16384 KB n = 8
15 Correct 17 ms 16484 KB n = 8
16 Correct 15 ms 16484 KB n = 8
17 Correct 14 ms 16524 KB n = 8
18 Correct 14 ms 16524 KB n = 8
19 Correct 17 ms 16524 KB n = 3
20 Correct 16 ms 16524 KB n = 7
21 Correct 15 ms 16524 KB n = 8
22 Correct 16 ms 16524 KB n = 8
23 Correct 18 ms 16524 KB n = 8
24 Correct 18 ms 16524 KB n = 8
25 Correct 17 ms 16524 KB n = 8
# Verdict Execution time Memory Grader output
1 Correct 15 ms 15992 KB n = 2
2 Correct 17 ms 16104 KB n = 2
3 Correct 15 ms 16204 KB n = 2
4 Correct 15 ms 16372 KB n = 2
5 Correct 16 ms 16372 KB n = 2
6 Correct 16 ms 16372 KB n = 2
7 Correct 16 ms 16372 KB n = 3
8 Correct 18 ms 16372 KB n = 3
9 Correct 15 ms 16372 KB n = 3
10 Correct 15 ms 16372 KB n = 8
11 Correct 18 ms 16372 KB n = 8
12 Correct 19 ms 16372 KB n = 8
13 Correct 18 ms 16372 KB n = 8
14 Correct 18 ms 16384 KB n = 8
15 Correct 17 ms 16484 KB n = 8
16 Correct 15 ms 16484 KB n = 8
17 Correct 14 ms 16524 KB n = 8
18 Correct 14 ms 16524 KB n = 8
19 Correct 17 ms 16524 KB n = 3
20 Correct 16 ms 16524 KB n = 7
21 Correct 15 ms 16524 KB n = 8
22 Correct 16 ms 16524 KB n = 8
23 Correct 18 ms 16524 KB n = 8
24 Correct 18 ms 16524 KB n = 8
25 Correct 17 ms 16524 KB n = 8
26 Correct 15 ms 16524 KB n = 8
27 Correct 14 ms 16524 KB n = 8
28 Correct 17 ms 16524 KB n = 8
29 Correct 64 ms 16524 KB n = 16
30 Correct 56 ms 16524 KB n = 16
31 Correct 83 ms 16524 KB n = 16
32 Correct 62 ms 16524 KB n = 16
33 Correct 60 ms 16524 KB n = 16
34 Correct 58 ms 16524 KB n = 16
35 Correct 59 ms 16524 KB n = 16
36 Correct 45 ms 16524 KB n = 15
37 Correct 14 ms 16524 KB n = 8
38 Correct 64 ms 16576 KB n = 16
39 Correct 63 ms 16576 KB n = 16
40 Correct 19 ms 16576 KB n = 9
41 Correct 69 ms 16640 KB n = 16
42 Correct 64 ms 16640 KB n = 16
43 Correct 63 ms 16640 KB n = 16
44 Correct 17 ms 16640 KB n = 9
45 Correct 39 ms 16640 KB n = 15
46 Correct 66 ms 16640 KB n = 16
47 Correct 66 ms 16664 KB n = 16
48 Correct 69 ms 16664 KB n = 16
# Verdict Execution time Memory Grader output
1 Runtime error 143 ms 42436 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 15 ms 15992 KB n = 2
2 Correct 17 ms 16104 KB n = 2
3 Correct 15 ms 16204 KB n = 2
4 Correct 15 ms 16372 KB n = 2
5 Correct 16 ms 16372 KB n = 2
6 Correct 16 ms 16372 KB n = 2
7 Correct 16 ms 16372 KB n = 3
8 Correct 18 ms 16372 KB n = 3
9 Correct 15 ms 16372 KB n = 3
10 Correct 15 ms 16372 KB n = 8
11 Correct 18 ms 16372 KB n = 8
12 Correct 19 ms 16372 KB n = 8
13 Correct 18 ms 16372 KB n = 8
14 Correct 18 ms 16384 KB n = 8
15 Correct 17 ms 16484 KB n = 8
16 Correct 15 ms 16484 KB n = 8
17 Correct 14 ms 16524 KB n = 8
18 Correct 14 ms 16524 KB n = 8
19 Correct 17 ms 16524 KB n = 3
20 Correct 16 ms 16524 KB n = 7
21 Correct 15 ms 16524 KB n = 8
22 Correct 16 ms 16524 KB n = 8
23 Correct 18 ms 16524 KB n = 8
24 Correct 18 ms 16524 KB n = 8
25 Correct 17 ms 16524 KB n = 8
26 Correct 15 ms 16524 KB n = 8
27 Correct 14 ms 16524 KB n = 8
28 Correct 17 ms 16524 KB n = 8
29 Correct 64 ms 16524 KB n = 16
30 Correct 56 ms 16524 KB n = 16
31 Correct 83 ms 16524 KB n = 16
32 Correct 62 ms 16524 KB n = 16
33 Correct 60 ms 16524 KB n = 16
34 Correct 58 ms 16524 KB n = 16
35 Correct 59 ms 16524 KB n = 16
36 Correct 45 ms 16524 KB n = 15
37 Correct 14 ms 16524 KB n = 8
38 Correct 64 ms 16576 KB n = 16
39 Correct 63 ms 16576 KB n = 16
40 Correct 19 ms 16576 KB n = 9
41 Correct 69 ms 16640 KB n = 16
42 Correct 64 ms 16640 KB n = 16
43 Correct 63 ms 16640 KB n = 16
44 Correct 17 ms 16640 KB n = 9
45 Correct 39 ms 16640 KB n = 15
46 Correct 66 ms 16640 KB n = 16
47 Correct 66 ms 16664 KB n = 16
48 Correct 69 ms 16664 KB n = 16
49 Runtime error 143 ms 42436 KB Execution killed with signal 11 (could be triggered by violating memory limits)
50 Halted 0 ms 0 KB -