Submission #100030

# Submission time Handle Problem Language Result Execution time Memory
100030 2019-03-09T06:51:06 Z ShaneOng Roller Coaster Railroad (IOI16_railroad) C++14
34 / 100
155 ms 9912 KB
#include "railroad.h"
#include <bits/stdc++.h>
#define INF 10000000000000009ll
using namespace std;
typedef long long ll;
int n;
ll memo[17][(1<<16)+10];
vector<int> a,b;
ll dp(int i, int bitmask){
    if(bitmask==((1<<n)-1)){
        //printf("test\n");
        return memo[i][bitmask]=0ll;
    }
    if(memo[i][bitmask]!=-1ll){
        return memo[i][bitmask];
    }
    //printf("%d %d\n",i,bitmask);
    memo[i][bitmask]=INF;
    for(int x=0;x<n;x++){
        if(((1<<x)&bitmask)==0){
            memo[i][bitmask]=min(memo[i][bitmask],dp(x,bitmask|(1<<x))+max(0ll,(ll)b[i]-a[x]));

        }
    }
    return memo[i][bitmask];
}
long long plan_roller_coaster(vector<int> s, vector<int> t) {
    n = (int) s.size();
    //printf("%d\n",n);
    a=s,b=t;
    for(int x=0;x<n;x++){
        for(int y=0;y<=(1<<n);y++)
            memo[x][y]=-1ll;
    }
    ll ans=INF;
    for(int x=0;x<n;x++)
        ans=min(ans,dp(x,(1<<x)));
    return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 384 KB n = 2
2 Correct 2 ms 256 KB n = 2
3 Correct 3 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 256 KB n = 8
12 Correct 3 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 2 ms 384 KB n = 8
17 Correct 2 ms 384 KB n = 8
18 Correct 3 ms 384 KB n = 8
19 Correct 3 ms 384 KB n = 3
20 Correct 2 ms 384 KB n = 7
21 Correct 3 ms 384 KB n = 8
22 Correct 2 ms 384 KB n = 8
23 Correct 2 ms 384 KB n = 8
24 Correct 2 ms 512 KB n = 8
25 Correct 2 ms 384 KB n = 8
# Verdict Execution time Memory Grader output
1 Correct 3 ms 384 KB n = 2
2 Correct 2 ms 256 KB n = 2
3 Correct 3 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 256 KB n = 8
12 Correct 3 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 2 ms 384 KB n = 8
17 Correct 2 ms 384 KB n = 8
18 Correct 3 ms 384 KB n = 8
19 Correct 3 ms 384 KB n = 3
20 Correct 2 ms 384 KB n = 7
21 Correct 3 ms 384 KB n = 8
22 Correct 2 ms 384 KB n = 8
23 Correct 2 ms 384 KB n = 8
24 Correct 2 ms 512 KB n = 8
25 Correct 2 ms 384 KB n = 8
26 Correct 3 ms 384 KB n = 8
27 Correct 2 ms 384 KB n = 8
28 Correct 2 ms 384 KB n = 8
29 Correct 94 ms 8576 KB n = 16
30 Correct 124 ms 8576 KB n = 16
31 Correct 127 ms 8576 KB n = 16
32 Correct 137 ms 8572 KB n = 16
33 Correct 144 ms 8568 KB n = 16
34 Correct 130 ms 8696 KB n = 16
35 Correct 123 ms 8696 KB n = 16
36 Correct 43 ms 4272 KB n = 15
37 Correct 2 ms 384 KB n = 8
38 Correct 113 ms 8580 KB n = 16
39 Correct 112 ms 8604 KB n = 16
40 Correct 3 ms 512 KB n = 9
41 Correct 130 ms 8576 KB n = 16
42 Correct 104 ms 8576 KB n = 16
43 Correct 96 ms 8580 KB n = 16
44 Correct 2 ms 384 KB n = 9
45 Correct 37 ms 4224 KB n = 15
46 Correct 121 ms 8576 KB n = 16
47 Correct 144 ms 8696 KB n = 16
48 Correct 155 ms 8576 KB n = 16
# Verdict Execution time Memory Grader output
1 Runtime error 93 ms 9912 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 3 ms 384 KB n = 2
2 Correct 2 ms 256 KB n = 2
3 Correct 3 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 256 KB n = 8
12 Correct 3 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 2 ms 384 KB n = 8
17 Correct 2 ms 384 KB n = 8
18 Correct 3 ms 384 KB n = 8
19 Correct 3 ms 384 KB n = 3
20 Correct 2 ms 384 KB n = 7
21 Correct 3 ms 384 KB n = 8
22 Correct 2 ms 384 KB n = 8
23 Correct 2 ms 384 KB n = 8
24 Correct 2 ms 512 KB n = 8
25 Correct 2 ms 384 KB n = 8
26 Correct 3 ms 384 KB n = 8
27 Correct 2 ms 384 KB n = 8
28 Correct 2 ms 384 KB n = 8
29 Correct 94 ms 8576 KB n = 16
30 Correct 124 ms 8576 KB n = 16
31 Correct 127 ms 8576 KB n = 16
32 Correct 137 ms 8572 KB n = 16
33 Correct 144 ms 8568 KB n = 16
34 Correct 130 ms 8696 KB n = 16
35 Correct 123 ms 8696 KB n = 16
36 Correct 43 ms 4272 KB n = 15
37 Correct 2 ms 384 KB n = 8
38 Correct 113 ms 8580 KB n = 16
39 Correct 112 ms 8604 KB n = 16
40 Correct 3 ms 512 KB n = 9
41 Correct 130 ms 8576 KB n = 16
42 Correct 104 ms 8576 KB n = 16
43 Correct 96 ms 8580 KB n = 16
44 Correct 2 ms 384 KB n = 9
45 Correct 37 ms 4224 KB n = 15
46 Correct 121 ms 8576 KB n = 16
47 Correct 144 ms 8696 KB n = 16
48 Correct 155 ms 8576 KB n = 16
49 Runtime error 93 ms 9912 KB Execution killed with signal 11 (could be triggered by violating memory limits)
50 Halted 0 ms 0 KB -