Submission #23735

# Submission time Handle Problem Language Result Execution time Memory
23735 2017-05-24T11:36:45 Z Nirjhor Roller Coaster Railroad (IOI16_railroad) C++14
34 / 100
123 ms 15944 KB
#include <bits/stdc++.h> 
#include "railroad.h"

using namespace std;

typedef long long ll;

const int N = 18;
const ll INF = 1e17 + 10;
const int MASK = (1 << 16) + 10;

int n, done;
vector <int> s, t;
ll dp[N][MASK];

ll call (int last, int mask) {
  if (mask == done) return 0;
  ll &ret = dp[last][mask];
  if (ret != -1) return ret;
  ret = INF;
  for (int i = 0; i < n; ++i) {
    if (mask & 1 << i) continue;
    ret = min(ret, (ll) max(0, t[last] - s[i]) + call(i, mask | 1 << i));
  }
  return ret;
}

ll plan_roller_coaster (vector <int> s_in, vector <int> t_in) {
  s = s_in, t = t_in;
  n = s.size();
  done = (1 << n) - 1;
  memset(dp, -1, sizeof dp);
  ll ans = INF;
  for (int i = 0; i < n; ++i) {
    ans = min(ans, call(i, 1 << i));
  }
  return ans;
}

// int main (int argc, char const *argv[]) {
//   int nn; cin >> nn;
//   vector <int> ss(nn), tt(nn);
//   for (int i = 0; i < nn; ++i) {
//     cin >> ss[i];
//   } 
//   for (int i = 0; i < nn; ++i) {
//     cin >> tt[i];
//   } 
//   cout << plan_roller_coaster(ss, tt) << endl;
//   return 0;
// }

# Verdict Execution time Memory Grader output
1 Correct 0 ms 11240 KB n = 2
2 Correct 0 ms 11240 KB n = 2
3 Correct 0 ms 11240 KB n = 2
4 Correct 0 ms 11240 KB n = 2
5 Correct 0 ms 11240 KB n = 2
6 Correct 0 ms 11240 KB n = 2
7 Correct 3 ms 11240 KB n = 3
8 Correct 0 ms 11240 KB n = 3
9 Correct 3 ms 11240 KB n = 3
10 Correct 3 ms 11240 KB n = 8
11 Correct 0 ms 11240 KB n = 8
12 Correct 0 ms 11240 KB n = 8
13 Correct 0 ms 11240 KB n = 8
14 Correct 0 ms 11240 KB n = 8
15 Correct 3 ms 11240 KB n = 8
16 Correct 3 ms 11240 KB n = 8
17 Correct 3 ms 11240 KB n = 8
18 Correct 0 ms 11240 KB n = 8
19 Correct 0 ms 11240 KB n = 3
20 Correct 0 ms 11240 KB n = 7
21 Correct 0 ms 11240 KB n = 8
22 Correct 0 ms 11240 KB n = 8
23 Correct 3 ms 11240 KB n = 8
24 Correct 3 ms 11240 KB n = 8
25 Correct 0 ms 11240 KB n = 8
# Verdict Execution time Memory Grader output
1 Correct 0 ms 11240 KB n = 2
2 Correct 0 ms 11240 KB n = 2
3 Correct 0 ms 11240 KB n = 2
4 Correct 0 ms 11240 KB n = 2
5 Correct 0 ms 11240 KB n = 2
6 Correct 0 ms 11240 KB n = 2
7 Correct 3 ms 11240 KB n = 3
8 Correct 0 ms 11240 KB n = 3
9 Correct 3 ms 11240 KB n = 3
10 Correct 3 ms 11240 KB n = 8
11 Correct 0 ms 11240 KB n = 8
12 Correct 0 ms 11240 KB n = 8
13 Correct 0 ms 11240 KB n = 8
14 Correct 0 ms 11240 KB n = 8
15 Correct 3 ms 11240 KB n = 8
16 Correct 3 ms 11240 KB n = 8
17 Correct 3 ms 11240 KB n = 8
18 Correct 0 ms 11240 KB n = 8
19 Correct 0 ms 11240 KB n = 3
20 Correct 0 ms 11240 KB n = 7
21 Correct 0 ms 11240 KB n = 8
22 Correct 0 ms 11240 KB n = 8
23 Correct 3 ms 11240 KB n = 8
24 Correct 3 ms 11240 KB n = 8
25 Correct 0 ms 11240 KB n = 8
26 Correct 0 ms 11240 KB n = 8
27 Correct 3 ms 11240 KB n = 8
28 Correct 3 ms 11240 KB n = 8
29 Correct 103 ms 11240 KB n = 16
30 Correct 83 ms 11240 KB n = 16
31 Correct 123 ms 11240 KB n = 16
32 Correct 99 ms 11240 KB n = 16
33 Correct 113 ms 11240 KB n = 16
34 Correct 96 ms 11240 KB n = 16
35 Correct 59 ms 11240 KB n = 16
36 Correct 46 ms 11240 KB n = 15
37 Correct 6 ms 11240 KB n = 8
38 Correct 99 ms 11240 KB n = 16
39 Correct 99 ms 11240 KB n = 16
40 Correct 0 ms 11240 KB n = 9
41 Correct 109 ms 11240 KB n = 16
42 Correct 66 ms 11240 KB n = 16
43 Correct 109 ms 11240 KB n = 16
44 Correct 0 ms 11240 KB n = 9
45 Correct 56 ms 11240 KB n = 15
46 Correct 109 ms 11240 KB n = 16
47 Correct 113 ms 11240 KB n = 16
48 Correct 116 ms 11240 KB n = 16
# Verdict Execution time Memory Grader output
1 Runtime error 86 ms 15944 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 0 ms 11240 KB n = 2
2 Correct 0 ms 11240 KB n = 2
3 Correct 0 ms 11240 KB n = 2
4 Correct 0 ms 11240 KB n = 2
5 Correct 0 ms 11240 KB n = 2
6 Correct 0 ms 11240 KB n = 2
7 Correct 3 ms 11240 KB n = 3
8 Correct 0 ms 11240 KB n = 3
9 Correct 3 ms 11240 KB n = 3
10 Correct 3 ms 11240 KB n = 8
11 Correct 0 ms 11240 KB n = 8
12 Correct 0 ms 11240 KB n = 8
13 Correct 0 ms 11240 KB n = 8
14 Correct 0 ms 11240 KB n = 8
15 Correct 3 ms 11240 KB n = 8
16 Correct 3 ms 11240 KB n = 8
17 Correct 3 ms 11240 KB n = 8
18 Correct 0 ms 11240 KB n = 8
19 Correct 0 ms 11240 KB n = 3
20 Correct 0 ms 11240 KB n = 7
21 Correct 0 ms 11240 KB n = 8
22 Correct 0 ms 11240 KB n = 8
23 Correct 3 ms 11240 KB n = 8
24 Correct 3 ms 11240 KB n = 8
25 Correct 0 ms 11240 KB n = 8
26 Correct 0 ms 11240 KB n = 8
27 Correct 3 ms 11240 KB n = 8
28 Correct 3 ms 11240 KB n = 8
29 Correct 103 ms 11240 KB n = 16
30 Correct 83 ms 11240 KB n = 16
31 Correct 123 ms 11240 KB n = 16
32 Correct 99 ms 11240 KB n = 16
33 Correct 113 ms 11240 KB n = 16
34 Correct 96 ms 11240 KB n = 16
35 Correct 59 ms 11240 KB n = 16
36 Correct 46 ms 11240 KB n = 15
37 Correct 6 ms 11240 KB n = 8
38 Correct 99 ms 11240 KB n = 16
39 Correct 99 ms 11240 KB n = 16
40 Correct 0 ms 11240 KB n = 9
41 Correct 109 ms 11240 KB n = 16
42 Correct 66 ms 11240 KB n = 16
43 Correct 109 ms 11240 KB n = 16
44 Correct 0 ms 11240 KB n = 9
45 Correct 56 ms 11240 KB n = 15
46 Correct 109 ms 11240 KB n = 16
47 Correct 113 ms 11240 KB n = 16
48 Correct 116 ms 11240 KB n = 16
49 Runtime error 86 ms 15944 KB Execution killed with signal 11 (could be triggered by violating memory limits)
50 Halted 0 ms 0 KB -