Submission #119162

# Submission time Handle Problem Language Result Execution time Memory
119162 2019-06-20T14:18:02 Z someone_aa Roller Coaster Railroad (IOI16_railroad) C++17
34 / 100
65 ms 10652 KB
#include "railroad.h"
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;
const int maxn = 17;
ll dp[maxn][(1<<maxn)], n;

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

    for(int i=1;i<(1<<n);i++) {
        //cout<<i<<": \n";
        for(int c=0;c<n;c++) {
            if(!((1<<c)&i)) continue;

            dp[c][i] = LLONG_MAX;
            if(__builtin_popcount(i) == 1) {
                dp[c][i] = 0;
            }
            else {
                for(int p=0;p<n;p++) {
                    if(!((1<<p)&i) || c == p) continue;
                    ll cost = max(0LL, 1LL * t[p] - s[c]);
                    dp[c][i] = min(dp[c][i], dp[p][(i^(1<<c))] + cost);
                }
            }
            //cout<<c<<" - "<<dp[c][i]<<"\n";
        }
    }

    ll result = LLONG_MAX;
    for(int i=0;i<n;i++) {
        result = min(result, dp[i][(1<<n)-1]);
    }

    return result;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB n = 2
2 Correct 2 ms 384 KB n = 2
3 Correct 2 ms 384 KB n = 2
4 Correct 2 ms 384 KB n = 2
5 Correct 2 ms 256 KB n = 2
6 Correct 2 ms 384 KB n = 2
7 Correct 2 ms 384 KB n = 3
8 Correct 2 ms 384 KB n = 3
9 Correct 2 ms 384 KB n = 3
10 Correct 2 ms 384 KB n = 8
11 Correct 2 ms 384 KB n = 8
12 Correct 2 ms 384 KB n = 8
13 Correct 2 ms 384 KB n = 8
14 Correct 2 ms 384 KB n = 8
15 Correct 2 ms 384 KB n = 8
16 Correct 3 ms 384 KB n = 8
17 Correct 2 ms 384 KB n = 8
18 Correct 2 ms 384 KB n = 8
19 Correct 2 ms 356 KB n = 3
20 Correct 2 ms 384 KB n = 7
21 Correct 2 ms 384 KB n = 8
22 Correct 2 ms 384 KB n = 8
23 Correct 2 ms 384 KB n = 8
24 Correct 3 ms 384 KB n = 8
25 Correct 2 ms 384 KB n = 8
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB n = 2
2 Correct 2 ms 384 KB n = 2
3 Correct 2 ms 384 KB n = 2
4 Correct 2 ms 384 KB n = 2
5 Correct 2 ms 256 KB n = 2
6 Correct 2 ms 384 KB n = 2
7 Correct 2 ms 384 KB n = 3
8 Correct 2 ms 384 KB n = 3
9 Correct 2 ms 384 KB n = 3
10 Correct 2 ms 384 KB n = 8
11 Correct 2 ms 384 KB n = 8
12 Correct 2 ms 384 KB n = 8
13 Correct 2 ms 384 KB n = 8
14 Correct 2 ms 384 KB n = 8
15 Correct 2 ms 384 KB n = 8
16 Correct 3 ms 384 KB n = 8
17 Correct 2 ms 384 KB n = 8
18 Correct 2 ms 384 KB n = 8
19 Correct 2 ms 356 KB n = 3
20 Correct 2 ms 384 KB n = 7
21 Correct 2 ms 384 KB n = 8
22 Correct 2 ms 384 KB n = 8
23 Correct 2 ms 384 KB n = 8
24 Correct 3 ms 384 KB n = 8
25 Correct 2 ms 384 KB n = 8
26 Correct 2 ms 384 KB n = 8
27 Correct 2 ms 384 KB n = 8
28 Correct 2 ms 384 KB n = 8
29 Correct 49 ms 7288 KB n = 16
30 Correct 50 ms 7288 KB n = 16
31 Correct 47 ms 7416 KB n = 16
32 Correct 47 ms 7288 KB n = 16
33 Correct 47 ms 7288 KB n = 16
34 Correct 47 ms 7272 KB n = 16
35 Correct 47 ms 7280 KB n = 16
36 Correct 22 ms 3712 KB n = 15
37 Correct 2 ms 384 KB n = 8
38 Correct 48 ms 7288 KB n = 16
39 Correct 47 ms 7288 KB n = 16
40 Correct 2 ms 356 KB n = 9
41 Correct 47 ms 7292 KB n = 16
42 Correct 49 ms 7260 KB n = 16
43 Correct 47 ms 7288 KB n = 16
44 Correct 2 ms 384 KB n = 9
45 Correct 22 ms 3712 KB n = 15
46 Correct 47 ms 7288 KB n = 16
47 Correct 48 ms 7324 KB n = 16
48 Correct 49 ms 7288 KB n = 16
# Verdict Execution time Memory Grader output
1 Runtime error 65 ms 10652 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 384 KB n = 2
2 Correct 2 ms 384 KB n = 2
3 Correct 2 ms 384 KB n = 2
4 Correct 2 ms 384 KB n = 2
5 Correct 2 ms 256 KB n = 2
6 Correct 2 ms 384 KB n = 2
7 Correct 2 ms 384 KB n = 3
8 Correct 2 ms 384 KB n = 3
9 Correct 2 ms 384 KB n = 3
10 Correct 2 ms 384 KB n = 8
11 Correct 2 ms 384 KB n = 8
12 Correct 2 ms 384 KB n = 8
13 Correct 2 ms 384 KB n = 8
14 Correct 2 ms 384 KB n = 8
15 Correct 2 ms 384 KB n = 8
16 Correct 3 ms 384 KB n = 8
17 Correct 2 ms 384 KB n = 8
18 Correct 2 ms 384 KB n = 8
19 Correct 2 ms 356 KB n = 3
20 Correct 2 ms 384 KB n = 7
21 Correct 2 ms 384 KB n = 8
22 Correct 2 ms 384 KB n = 8
23 Correct 2 ms 384 KB n = 8
24 Correct 3 ms 384 KB n = 8
25 Correct 2 ms 384 KB n = 8
26 Correct 2 ms 384 KB n = 8
27 Correct 2 ms 384 KB n = 8
28 Correct 2 ms 384 KB n = 8
29 Correct 49 ms 7288 KB n = 16
30 Correct 50 ms 7288 KB n = 16
31 Correct 47 ms 7416 KB n = 16
32 Correct 47 ms 7288 KB n = 16
33 Correct 47 ms 7288 KB n = 16
34 Correct 47 ms 7272 KB n = 16
35 Correct 47 ms 7280 KB n = 16
36 Correct 22 ms 3712 KB n = 15
37 Correct 2 ms 384 KB n = 8
38 Correct 48 ms 7288 KB n = 16
39 Correct 47 ms 7288 KB n = 16
40 Correct 2 ms 356 KB n = 9
41 Correct 47 ms 7292 KB n = 16
42 Correct 49 ms 7260 KB n = 16
43 Correct 47 ms 7288 KB n = 16
44 Correct 2 ms 384 KB n = 9
45 Correct 22 ms 3712 KB n = 15
46 Correct 47 ms 7288 KB n = 16
47 Correct 48 ms 7324 KB n = 16
48 Correct 49 ms 7288 KB n = 16
49 Runtime error 65 ms 10652 KB Execution killed with signal 11 (could be triggered by violating memory limits)
50 Halted 0 ms 0 KB -