Submission #72982

# Submission time Handle Problem Language Result Execution time Memory
72982 2018-08-27T12:06:20 Z MKopchev Roller Coaster Railroad (IOI16_railroad) C++14
34 / 100
141 ms 11020 KB
#include<bits/stdc++.h>
using namespace std;
const int nmax=16;
int n;
long long dp[1<<nmax][nmax];
vector<int> s,t;
long long rec(int state/*1->active, 0->used*/,int last)
{
    if(state==0)return 0;
    if(dp[state][last]!=-1)return dp[state][last];
    long long ret=1e18;
    for(int i=0;i<n;i++)
        if((state&(1<<i)))
        {
            if(t[last]<=s[i])ret=min(ret,rec(state-(1<<i),i));
            else ret=min(ret,rec(state-(1<<i),i)+t[last]-s[i]);
        }
    dp[state][last]=ret;
    return ret;
}
long long plan_roller_coaster(vector<int> S, vector<int> T)
{
    n=S.size();
    assert(n<=nmax);
    memset(dp,-1,sizeof(dp));
    for(int i=0;i<n;i++)s.push_back(S[i]),t.push_back(T[i]);
    long long ans=1e18;
    for(int i=0;i<n;i++)
        ans=min(ans,rec((1<<n)-1-(1<<i),i));
    return ans;
}
/*
int main()
{
    cout<<plan_roller_coaster({1, 4, 5, 6}, {7, 3, 8, 6})<<endl;
}
*/
# Verdict Execution time Memory Grader output
1 Correct 8 ms 8440 KB n = 2
2 Correct 10 ms 8676 KB n = 2
3 Correct 8 ms 8696 KB n = 2
4 Correct 10 ms 8760 KB n = 2
5 Correct 10 ms 8760 KB n = 2
6 Correct 9 ms 8760 KB n = 2
7 Correct 10 ms 8760 KB n = 3
8 Correct 10 ms 8812 KB n = 3
9 Correct 9 ms 8812 KB n = 3
10 Correct 10 ms 8868 KB n = 8
11 Correct 9 ms 8872 KB n = 8
12 Correct 9 ms 8872 KB n = 8
13 Correct 9 ms 8872 KB n = 8
14 Correct 8 ms 8872 KB n = 8
15 Correct 8 ms 8872 KB n = 8
16 Correct 9 ms 8872 KB n = 8
17 Correct 9 ms 8872 KB n = 8
18 Correct 8 ms 8872 KB n = 8
19 Correct 9 ms 8872 KB n = 3
20 Correct 9 ms 8872 KB n = 7
21 Correct 10 ms 8872 KB n = 8
22 Correct 10 ms 8872 KB n = 8
23 Correct 11 ms 8872 KB n = 8
24 Correct 10 ms 8872 KB n = 8
25 Correct 12 ms 8872 KB n = 8
# Verdict Execution time Memory Grader output
1 Correct 8 ms 8440 KB n = 2
2 Correct 10 ms 8676 KB n = 2
3 Correct 8 ms 8696 KB n = 2
4 Correct 10 ms 8760 KB n = 2
5 Correct 10 ms 8760 KB n = 2
6 Correct 9 ms 8760 KB n = 2
7 Correct 10 ms 8760 KB n = 3
8 Correct 10 ms 8812 KB n = 3
9 Correct 9 ms 8812 KB n = 3
10 Correct 10 ms 8868 KB n = 8
11 Correct 9 ms 8872 KB n = 8
12 Correct 9 ms 8872 KB n = 8
13 Correct 9 ms 8872 KB n = 8
14 Correct 8 ms 8872 KB n = 8
15 Correct 8 ms 8872 KB n = 8
16 Correct 9 ms 8872 KB n = 8
17 Correct 9 ms 8872 KB n = 8
18 Correct 8 ms 8872 KB n = 8
19 Correct 9 ms 8872 KB n = 3
20 Correct 9 ms 8872 KB n = 7
21 Correct 10 ms 8872 KB n = 8
22 Correct 10 ms 8872 KB n = 8
23 Correct 11 ms 8872 KB n = 8
24 Correct 10 ms 8872 KB n = 8
25 Correct 12 ms 8872 KB n = 8
26 Correct 10 ms 8872 KB n = 8
27 Correct 10 ms 8872 KB n = 8
28 Correct 10 ms 8872 KB n = 8
29 Correct 107 ms 8872 KB n = 16
30 Correct 108 ms 8944 KB n = 16
31 Correct 111 ms 8944 KB n = 16
32 Correct 103 ms 8944 KB n = 16
33 Correct 109 ms 8944 KB n = 16
34 Correct 117 ms 8944 KB n = 16
35 Correct 123 ms 8944 KB n = 16
36 Correct 51 ms 8944 KB n = 15
37 Correct 10 ms 8944 KB n = 8
38 Correct 141 ms 8944 KB n = 16
39 Correct 103 ms 8944 KB n = 16
40 Correct 10 ms 8948 KB n = 9
41 Correct 121 ms 8956 KB n = 16
42 Correct 106 ms 8976 KB n = 16
43 Correct 108 ms 8976 KB n = 16
44 Correct 11 ms 8976 KB n = 9
45 Correct 52 ms 8976 KB n = 15
46 Correct 110 ms 8976 KB n = 16
47 Correct 106 ms 8976 KB n = 16
48 Correct 123 ms 8976 KB n = 16
# Verdict Execution time Memory Grader output
1 Runtime error 103 ms 11020 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 8 ms 8440 KB n = 2
2 Correct 10 ms 8676 KB n = 2
3 Correct 8 ms 8696 KB n = 2
4 Correct 10 ms 8760 KB n = 2
5 Correct 10 ms 8760 KB n = 2
6 Correct 9 ms 8760 KB n = 2
7 Correct 10 ms 8760 KB n = 3
8 Correct 10 ms 8812 KB n = 3
9 Correct 9 ms 8812 KB n = 3
10 Correct 10 ms 8868 KB n = 8
11 Correct 9 ms 8872 KB n = 8
12 Correct 9 ms 8872 KB n = 8
13 Correct 9 ms 8872 KB n = 8
14 Correct 8 ms 8872 KB n = 8
15 Correct 8 ms 8872 KB n = 8
16 Correct 9 ms 8872 KB n = 8
17 Correct 9 ms 8872 KB n = 8
18 Correct 8 ms 8872 KB n = 8
19 Correct 9 ms 8872 KB n = 3
20 Correct 9 ms 8872 KB n = 7
21 Correct 10 ms 8872 KB n = 8
22 Correct 10 ms 8872 KB n = 8
23 Correct 11 ms 8872 KB n = 8
24 Correct 10 ms 8872 KB n = 8
25 Correct 12 ms 8872 KB n = 8
26 Correct 10 ms 8872 KB n = 8
27 Correct 10 ms 8872 KB n = 8
28 Correct 10 ms 8872 KB n = 8
29 Correct 107 ms 8872 KB n = 16
30 Correct 108 ms 8944 KB n = 16
31 Correct 111 ms 8944 KB n = 16
32 Correct 103 ms 8944 KB n = 16
33 Correct 109 ms 8944 KB n = 16
34 Correct 117 ms 8944 KB n = 16
35 Correct 123 ms 8944 KB n = 16
36 Correct 51 ms 8944 KB n = 15
37 Correct 10 ms 8944 KB n = 8
38 Correct 141 ms 8944 KB n = 16
39 Correct 103 ms 8944 KB n = 16
40 Correct 10 ms 8948 KB n = 9
41 Correct 121 ms 8956 KB n = 16
42 Correct 106 ms 8976 KB n = 16
43 Correct 108 ms 8976 KB n = 16
44 Correct 11 ms 8976 KB n = 9
45 Correct 52 ms 8976 KB n = 15
46 Correct 110 ms 8976 KB n = 16
47 Correct 106 ms 8976 KB n = 16
48 Correct 123 ms 8976 KB n = 16
49 Runtime error 103 ms 11020 KB Execution killed with signal 11 (could be triggered by violating memory limits)
50 Halted 0 ms 0 KB -