Submission #991602

# Submission time Handle Problem Language Result Execution time Memory
991602 2024-06-02T15:11:30 Z KasymK Roller Coaster Railroad (IOI16_railroad) C++17
34 / 100
261 ms 524288 KB
#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18;

long long plan_roller_coaster(vector<int> s, vector<int> t){
    int n = (int)s.size();
    long long dp[(1<<n)][n];
    for(int mk = 0; mk < (1<<n); ++mk)
        for(int i = 0; i < n; ++i)
            dp[mk][i] = INF;
    for(int mk = 0; mk < n; ++mk)
        dp[(1<<mk)][mk] = 0;
    for(int mk = 0; mk < (1<<n); ++mk)
        for(int i = 0; i < n; ++i)
            if(mk>>i&1){
                int mk2 = mk-(1<<i);
                for(int j = 0; j < n; ++j)
                    if(mk2>>j&1)
                        dp[mk][i] = min(dp[mk][i], dp[mk2][j]+max(0, t[j]-s[i]));
            }
    long long answer = INF;
    for(int i = 0; i < n; ++i)
        answer = min(answer, dp[(1<<n)-1][i]);
    return answer;
}

// int main(){
//     long long answer = plan_roller_coaster({1, 4, 5, 6}, {7, 3, 8, 6});
//     printf("%lld", answer);
//     return 0;
// }
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB n = 2
2 Correct 1 ms 348 KB n = 2
3 Correct 0 ms 348 KB n = 2
4 Correct 0 ms 348 KB n = 2
5 Correct 0 ms 436 KB n = 2
6 Correct 0 ms 348 KB n = 2
7 Correct 0 ms 348 KB n = 3
8 Correct 1 ms 348 KB n = 3
9 Correct 0 ms 348 KB n = 3
10 Correct 0 ms 348 KB n = 8
11 Correct 0 ms 348 KB n = 8
12 Correct 0 ms 344 KB n = 8
13 Correct 0 ms 348 KB n = 8
14 Correct 0 ms 348 KB n = 8
15 Correct 0 ms 348 KB n = 8
16 Correct 0 ms 436 KB n = 8
17 Correct 0 ms 348 KB n = 8
18 Correct 0 ms 348 KB n = 8
19 Correct 0 ms 348 KB n = 3
20 Correct 1 ms 348 KB n = 7
21 Correct 0 ms 348 KB n = 8
22 Correct 1 ms 348 KB n = 8
23 Correct 0 ms 348 KB n = 8
24 Correct 0 ms 348 KB n = 8
25 Correct 0 ms 348 KB n = 8
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB n = 2
2 Correct 1 ms 348 KB n = 2
3 Correct 0 ms 348 KB n = 2
4 Correct 0 ms 348 KB n = 2
5 Correct 0 ms 436 KB n = 2
6 Correct 0 ms 348 KB n = 2
7 Correct 0 ms 348 KB n = 3
8 Correct 1 ms 348 KB n = 3
9 Correct 0 ms 348 KB n = 3
10 Correct 0 ms 348 KB n = 8
11 Correct 0 ms 348 KB n = 8
12 Correct 0 ms 344 KB n = 8
13 Correct 0 ms 348 KB n = 8
14 Correct 0 ms 348 KB n = 8
15 Correct 0 ms 348 KB n = 8
16 Correct 0 ms 436 KB n = 8
17 Correct 0 ms 348 KB n = 8
18 Correct 0 ms 348 KB n = 8
19 Correct 0 ms 348 KB n = 3
20 Correct 1 ms 348 KB n = 7
21 Correct 0 ms 348 KB n = 8
22 Correct 1 ms 348 KB n = 8
23 Correct 0 ms 348 KB n = 8
24 Correct 0 ms 348 KB n = 8
25 Correct 0 ms 348 KB n = 8
26 Correct 0 ms 348 KB n = 8
27 Correct 0 ms 348 KB n = 8
28 Correct 0 ms 348 KB n = 8
29 Correct 31 ms 8536 KB n = 16
30 Correct 31 ms 8540 KB n = 16
31 Correct 31 ms 8540 KB n = 16
32 Correct 31 ms 8540 KB n = 16
33 Correct 32 ms 8540 KB n = 16
34 Correct 34 ms 8540 KB n = 16
35 Correct 31 ms 8540 KB n = 16
36 Correct 18 ms 4188 KB n = 15
37 Correct 0 ms 348 KB n = 8
38 Correct 32 ms 8632 KB n = 16
39 Correct 32 ms 8540 KB n = 16
40 Correct 0 ms 348 KB n = 9
41 Correct 35 ms 8540 KB n = 16
42 Correct 32 ms 8540 KB n = 16
43 Correct 31 ms 8540 KB n = 16
44 Correct 1 ms 348 KB n = 9
45 Correct 19 ms 4280 KB n = 15
46 Correct 38 ms 8540 KB n = 16
47 Correct 31 ms 8540 KB n = 16
48 Correct 35 ms 8540 KB n = 16
# Verdict Execution time Memory Grader output
1 Runtime error 261 ms 524288 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB n = 2
2 Correct 1 ms 348 KB n = 2
3 Correct 0 ms 348 KB n = 2
4 Correct 0 ms 348 KB n = 2
5 Correct 0 ms 436 KB n = 2
6 Correct 0 ms 348 KB n = 2
7 Correct 0 ms 348 KB n = 3
8 Correct 1 ms 348 KB n = 3
9 Correct 0 ms 348 KB n = 3
10 Correct 0 ms 348 KB n = 8
11 Correct 0 ms 348 KB n = 8
12 Correct 0 ms 344 KB n = 8
13 Correct 0 ms 348 KB n = 8
14 Correct 0 ms 348 KB n = 8
15 Correct 0 ms 348 KB n = 8
16 Correct 0 ms 436 KB n = 8
17 Correct 0 ms 348 KB n = 8
18 Correct 0 ms 348 KB n = 8
19 Correct 0 ms 348 KB n = 3
20 Correct 1 ms 348 KB n = 7
21 Correct 0 ms 348 KB n = 8
22 Correct 1 ms 348 KB n = 8
23 Correct 0 ms 348 KB n = 8
24 Correct 0 ms 348 KB n = 8
25 Correct 0 ms 348 KB n = 8
26 Correct 0 ms 348 KB n = 8
27 Correct 0 ms 348 KB n = 8
28 Correct 0 ms 348 KB n = 8
29 Correct 31 ms 8536 KB n = 16
30 Correct 31 ms 8540 KB n = 16
31 Correct 31 ms 8540 KB n = 16
32 Correct 31 ms 8540 KB n = 16
33 Correct 32 ms 8540 KB n = 16
34 Correct 34 ms 8540 KB n = 16
35 Correct 31 ms 8540 KB n = 16
36 Correct 18 ms 4188 KB n = 15
37 Correct 0 ms 348 KB n = 8
38 Correct 32 ms 8632 KB n = 16
39 Correct 32 ms 8540 KB n = 16
40 Correct 0 ms 348 KB n = 9
41 Correct 35 ms 8540 KB n = 16
42 Correct 32 ms 8540 KB n = 16
43 Correct 31 ms 8540 KB n = 16
44 Correct 1 ms 348 KB n = 9
45 Correct 19 ms 4280 KB n = 15
46 Correct 38 ms 8540 KB n = 16
47 Correct 31 ms 8540 KB n = 16
48 Correct 35 ms 8540 KB n = 16
49 Runtime error 261 ms 524288 KB Execution killed with signal 9
50 Halted 0 ms 0 KB -