Submission #47298

# Submission time Handle Problem Language Result Execution time Memory
47298 2018-04-30T10:33:57 Z TAMREF Roller Coaster Railroad (IOI16_railroad) C++11
34 / 100
75 ms 9116 KB
#include "railroad.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

ll dp[16][1<<16];

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

    if(n > 16) return 42;
    for(int i = 0; i < n; i++) fill(dp[i], dp[i] + (1 << n), LLONG_MAX);
    for(int i = 0; i < n; i++) dp[i][1<<i] = 0;

    for(int b = 1; b < (1 << n); b++){
        for(int i = 0; i < n; i++){
            if(!(b >> i & 1)) continue;
            for(int j = 0; j < n; j++){
                if(b >> j & 1) continue;
                ll &d = dp[j][b | (1 << j)];
                d = min(d, dp[i][b] + max(0, t[i]-s[j]));
            }
        }
    }
    ll ans = LLONG_MAX;
    for(int i = 0; i < n; i++){
        ans = min(ans, dp[i][(1<<n)-1]);
    }
    return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB n = 2
2 Correct 2 ms 360 KB n = 2
3 Correct 2 ms 604 KB n = 2
4 Correct 2 ms 604 KB n = 2
5 Correct 2 ms 640 KB n = 2
6 Correct 2 ms 660 KB n = 2
7 Correct 2 ms 700 KB n = 3
8 Correct 2 ms 824 KB n = 3
9 Correct 2 ms 824 KB n = 3
10 Correct 2 ms 884 KB n = 8
11 Correct 2 ms 884 KB n = 8
12 Correct 2 ms 884 KB n = 8
13 Correct 2 ms 884 KB n = 8
14 Correct 2 ms 884 KB n = 8
15 Correct 2 ms 884 KB n = 8
16 Correct 2 ms 884 KB n = 8
17 Correct 2 ms 920 KB n = 8
18 Correct 2 ms 920 KB n = 8
19 Correct 2 ms 920 KB n = 3
20 Correct 2 ms 920 KB n = 7
21 Correct 2 ms 920 KB n = 8
22 Correct 2 ms 920 KB n = 8
23 Correct 2 ms 920 KB n = 8
24 Correct 2 ms 952 KB n = 8
25 Correct 2 ms 952 KB n = 8
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB n = 2
2 Correct 2 ms 360 KB n = 2
3 Correct 2 ms 604 KB n = 2
4 Correct 2 ms 604 KB n = 2
5 Correct 2 ms 640 KB n = 2
6 Correct 2 ms 660 KB n = 2
7 Correct 2 ms 700 KB n = 3
8 Correct 2 ms 824 KB n = 3
9 Correct 2 ms 824 KB n = 3
10 Correct 2 ms 884 KB n = 8
11 Correct 2 ms 884 KB n = 8
12 Correct 2 ms 884 KB n = 8
13 Correct 2 ms 884 KB n = 8
14 Correct 2 ms 884 KB n = 8
15 Correct 2 ms 884 KB n = 8
16 Correct 2 ms 884 KB n = 8
17 Correct 2 ms 920 KB n = 8
18 Correct 2 ms 920 KB n = 8
19 Correct 2 ms 920 KB n = 3
20 Correct 2 ms 920 KB n = 7
21 Correct 2 ms 920 KB n = 8
22 Correct 2 ms 920 KB n = 8
23 Correct 2 ms 920 KB n = 8
24 Correct 2 ms 952 KB n = 8
25 Correct 2 ms 952 KB n = 8
26 Correct 2 ms 952 KB n = 8
27 Correct 2 ms 952 KB n = 8
28 Correct 2 ms 952 KB n = 8
29 Correct 46 ms 9040 KB n = 16
30 Correct 45 ms 9044 KB n = 16
31 Correct 46 ms 9048 KB n = 16
32 Correct 45 ms 9052 KB n = 16
33 Correct 48 ms 9060 KB n = 16
34 Correct 46 ms 9060 KB n = 16
35 Correct 62 ms 9060 KB n = 16
36 Correct 22 ms 9060 KB n = 15
37 Correct 2 ms 9060 KB n = 8
38 Correct 48 ms 9076 KB n = 16
39 Correct 57 ms 9084 KB n = 16
40 Correct 2 ms 9084 KB n = 9
41 Correct 48 ms 9088 KB n = 16
42 Correct 52 ms 9092 KB n = 16
43 Correct 58 ms 9096 KB n = 16
44 Correct 2 ms 9096 KB n = 9
45 Correct 22 ms 9096 KB n = 15
46 Correct 63 ms 9096 KB n = 16
47 Correct 51 ms 9112 KB n = 16
48 Correct 50 ms 9116 KB n = 16
# Verdict Execution time Memory Grader output
1 Incorrect 75 ms 9116 KB answer is not correct: 1 instead of 0
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB n = 2
2 Correct 2 ms 360 KB n = 2
3 Correct 2 ms 604 KB n = 2
4 Correct 2 ms 604 KB n = 2
5 Correct 2 ms 640 KB n = 2
6 Correct 2 ms 660 KB n = 2
7 Correct 2 ms 700 KB n = 3
8 Correct 2 ms 824 KB n = 3
9 Correct 2 ms 824 KB n = 3
10 Correct 2 ms 884 KB n = 8
11 Correct 2 ms 884 KB n = 8
12 Correct 2 ms 884 KB n = 8
13 Correct 2 ms 884 KB n = 8
14 Correct 2 ms 884 KB n = 8
15 Correct 2 ms 884 KB n = 8
16 Correct 2 ms 884 KB n = 8
17 Correct 2 ms 920 KB n = 8
18 Correct 2 ms 920 KB n = 8
19 Correct 2 ms 920 KB n = 3
20 Correct 2 ms 920 KB n = 7
21 Correct 2 ms 920 KB n = 8
22 Correct 2 ms 920 KB n = 8
23 Correct 2 ms 920 KB n = 8
24 Correct 2 ms 952 KB n = 8
25 Correct 2 ms 952 KB n = 8
26 Correct 2 ms 952 KB n = 8
27 Correct 2 ms 952 KB n = 8
28 Correct 2 ms 952 KB n = 8
29 Correct 46 ms 9040 KB n = 16
30 Correct 45 ms 9044 KB n = 16
31 Correct 46 ms 9048 KB n = 16
32 Correct 45 ms 9052 KB n = 16
33 Correct 48 ms 9060 KB n = 16
34 Correct 46 ms 9060 KB n = 16
35 Correct 62 ms 9060 KB n = 16
36 Correct 22 ms 9060 KB n = 15
37 Correct 2 ms 9060 KB n = 8
38 Correct 48 ms 9076 KB n = 16
39 Correct 57 ms 9084 KB n = 16
40 Correct 2 ms 9084 KB n = 9
41 Correct 48 ms 9088 KB n = 16
42 Correct 52 ms 9092 KB n = 16
43 Correct 58 ms 9096 KB n = 16
44 Correct 2 ms 9096 KB n = 9
45 Correct 22 ms 9096 KB n = 15
46 Correct 63 ms 9096 KB n = 16
47 Correct 51 ms 9112 KB n = 16
48 Correct 50 ms 9116 KB n = 16
49 Incorrect 75 ms 9116 KB answer is not correct: 1 instead of 0
50 Halted 0 ms 0 KB -