#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll INF = 1000000000000000000LL;
ll n, m, q, k, x, y, a, b, c;
long long plan_roller_coaster(vector<int> s, vector<int> t) {
n = (int) s.size();
if (n <= 16) {
vector< vector<ll> > dp((1 << n), vector<ll>(n, INF));
ll ans = INF;
for (int i = 1; i < (1 << n); i++) {
vector<int> v;
for (int j = 0; j < n; j++) {
if ((i >> j) & 1) {
v.push_back(j);
}
}
for (auto j : v) {
if (v.size() == 1) {
dp[i][j] = 0;
}
else {
for (int k = 0; k < n; k++) {
if (!((i >> k) & 1) || j == k) {
continue;
}
dp[i][j] = min(dp[i][j], dp[i - (1 << j)][k] + max(0, t[k] - s[j]));
}
}
if (v.size() == n) {
ans = min(ans, dp[i][j]);
}
// cout << bitset<4>(i) << ' ' << j << ' ' << dp[i][j] << '\n';
}
}
return ans;
}
vector< pair<ll, ll> > v;
for (int i = 0; i < n; i++) {
v.push_back({t[i], s[i]});
}
sort(v.rbegin(), v.rend());
sort(s.rbegin(), s.rend());
ll e = 0;
for (int i = 0; i < n; i++) {
while (e < n && s[e] >= v[i].first) {
e++;
}
if (e - (v[i].second >= v[i].first ? 1 : 0) < i) {
return 1;
}
}
return 0;
}
Compilation message
railroad.cpp: In function 'long long int plan_roller_coaster(std::vector<int>, std::vector<int>)':
railroad.cpp:34:30: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'll' {aka 'long long int'} [-Wsign-compare]
34 | if (v.size() == n) {
| ~~~~~~~~~^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
n = 2 |
2 |
Correct |
0 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 |
348 KB |
n = 2 |
6 |
Correct |
0 ms |
348 KB |
n = 2 |
7 |
Correct |
0 ms |
344 KB |
n = 3 |
8 |
Correct |
0 ms |
348 KB |
n = 3 |
9 |
Correct |
0 ms |
348 KB |
n = 3 |
10 |
Correct |
0 ms |
348 KB |
n = 8 |
11 |
Correct |
1 ms |
348 KB |
n = 8 |
12 |
Correct |
1 ms |
348 KB |
n = 8 |
13 |
Correct |
0 ms |
344 KB |
n = 8 |
14 |
Correct |
1 ms |
348 KB |
n = 8 |
15 |
Correct |
1 ms |
348 KB |
n = 8 |
16 |
Correct |
1 ms |
348 KB |
n = 8 |
17 |
Correct |
0 ms |
348 KB |
n = 8 |
18 |
Correct |
1 ms |
348 KB |
n = 8 |
19 |
Correct |
1 ms |
344 KB |
n = 3 |
20 |
Correct |
0 ms |
600 KB |
n = 7 |
21 |
Correct |
1 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 |
1 ms |
348 KB |
n = 2 |
2 |
Correct |
0 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 |
348 KB |
n = 2 |
6 |
Correct |
0 ms |
348 KB |
n = 2 |
7 |
Correct |
0 ms |
344 KB |
n = 3 |
8 |
Correct |
0 ms |
348 KB |
n = 3 |
9 |
Correct |
0 ms |
348 KB |
n = 3 |
10 |
Correct |
0 ms |
348 KB |
n = 8 |
11 |
Correct |
1 ms |
348 KB |
n = 8 |
12 |
Correct |
1 ms |
348 KB |
n = 8 |
13 |
Correct |
0 ms |
344 KB |
n = 8 |
14 |
Correct |
1 ms |
348 KB |
n = 8 |
15 |
Correct |
1 ms |
348 KB |
n = 8 |
16 |
Correct |
1 ms |
348 KB |
n = 8 |
17 |
Correct |
0 ms |
348 KB |
n = 8 |
18 |
Correct |
1 ms |
348 KB |
n = 8 |
19 |
Correct |
1 ms |
344 KB |
n = 3 |
20 |
Correct |
0 ms |
600 KB |
n = 7 |
21 |
Correct |
1 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 |
1 ms |
348 KB |
n = 8 |
27 |
Correct |
0 ms |
348 KB |
n = 8 |
28 |
Correct |
0 ms |
348 KB |
n = 8 |
29 |
Correct |
49 ms |
11100 KB |
n = 16 |
30 |
Correct |
43 ms |
11100 KB |
n = 16 |
31 |
Correct |
64 ms |
11100 KB |
n = 16 |
32 |
Correct |
62 ms |
11096 KB |
n = 16 |
33 |
Correct |
58 ms |
11100 KB |
n = 16 |
34 |
Correct |
45 ms |
11096 KB |
n = 16 |
35 |
Correct |
43 ms |
11100 KB |
n = 16 |
36 |
Correct |
21 ms |
5212 KB |
n = 15 |
37 |
Correct |
1 ms |
348 KB |
n = 8 |
38 |
Correct |
54 ms |
10968 KB |
n = 16 |
39 |
Correct |
60 ms |
11100 KB |
n = 16 |
40 |
Correct |
1 ms |
344 KB |
n = 9 |
41 |
Correct |
44 ms |
11152 KB |
n = 16 |
42 |
Correct |
59 ms |
11100 KB |
n = 16 |
43 |
Correct |
45 ms |
11096 KB |
n = 16 |
44 |
Correct |
1 ms |
348 KB |
n = 9 |
45 |
Correct |
29 ms |
5208 KB |
n = 15 |
46 |
Correct |
53 ms |
11024 KB |
n = 16 |
47 |
Correct |
46 ms |
11100 KB |
n = 16 |
48 |
Correct |
54 ms |
11096 KB |
n = 16 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
66 ms |
9664 KB |
n = 199999 |
2 |
Correct |
67 ms |
7760 KB |
n = 199991 |
3 |
Correct |
69 ms |
9412 KB |
n = 199993 |
4 |
Correct |
94 ms |
7528 KB |
n = 152076 |
5 |
Correct |
31 ms |
4044 KB |
n = 93249 |
6 |
Correct |
61 ms |
7872 KB |
n = 199910 |
7 |
Correct |
56 ms |
9028 KB |
n = 199999 |
8 |
Correct |
85 ms |
9544 KB |
n = 199997 |
9 |
Correct |
52 ms |
8564 KB |
n = 171294 |
10 |
Correct |
40 ms |
7372 KB |
n = 140872 |
11 |
Correct |
81 ms |
12228 KB |
n = 199886 |
12 |
Correct |
63 ms |
10940 KB |
n = 199996 |
13 |
Correct |
57 ms |
10436 KB |
n = 200000 |
14 |
Correct |
64 ms |
11064 KB |
n = 199998 |
15 |
Correct |
83 ms |
12728 KB |
n = 200000 |
16 |
Correct |
62 ms |
12228 KB |
n = 199998 |
17 |
Correct |
60 ms |
13624 KB |
n = 200000 |
18 |
Correct |
85 ms |
12120 KB |
n = 190000 |
19 |
Correct |
51 ms |
11204 KB |
n = 177777 |
20 |
Incorrect |
44 ms |
6096 KB |
answer is not correct: 1 instead of 0 |
21 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
n = 2 |
2 |
Correct |
0 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 |
348 KB |
n = 2 |
6 |
Correct |
0 ms |
348 KB |
n = 2 |
7 |
Correct |
0 ms |
344 KB |
n = 3 |
8 |
Correct |
0 ms |
348 KB |
n = 3 |
9 |
Correct |
0 ms |
348 KB |
n = 3 |
10 |
Correct |
0 ms |
348 KB |
n = 8 |
11 |
Correct |
1 ms |
348 KB |
n = 8 |
12 |
Correct |
1 ms |
348 KB |
n = 8 |
13 |
Correct |
0 ms |
344 KB |
n = 8 |
14 |
Correct |
1 ms |
348 KB |
n = 8 |
15 |
Correct |
1 ms |
348 KB |
n = 8 |
16 |
Correct |
1 ms |
348 KB |
n = 8 |
17 |
Correct |
0 ms |
348 KB |
n = 8 |
18 |
Correct |
1 ms |
348 KB |
n = 8 |
19 |
Correct |
1 ms |
344 KB |
n = 3 |
20 |
Correct |
0 ms |
600 KB |
n = 7 |
21 |
Correct |
1 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 |
1 ms |
348 KB |
n = 8 |
27 |
Correct |
0 ms |
348 KB |
n = 8 |
28 |
Correct |
0 ms |
348 KB |
n = 8 |
29 |
Correct |
49 ms |
11100 KB |
n = 16 |
30 |
Correct |
43 ms |
11100 KB |
n = 16 |
31 |
Correct |
64 ms |
11100 KB |
n = 16 |
32 |
Correct |
62 ms |
11096 KB |
n = 16 |
33 |
Correct |
58 ms |
11100 KB |
n = 16 |
34 |
Correct |
45 ms |
11096 KB |
n = 16 |
35 |
Correct |
43 ms |
11100 KB |
n = 16 |
36 |
Correct |
21 ms |
5212 KB |
n = 15 |
37 |
Correct |
1 ms |
348 KB |
n = 8 |
38 |
Correct |
54 ms |
10968 KB |
n = 16 |
39 |
Correct |
60 ms |
11100 KB |
n = 16 |
40 |
Correct |
1 ms |
344 KB |
n = 9 |
41 |
Correct |
44 ms |
11152 KB |
n = 16 |
42 |
Correct |
59 ms |
11100 KB |
n = 16 |
43 |
Correct |
45 ms |
11096 KB |
n = 16 |
44 |
Correct |
1 ms |
348 KB |
n = 9 |
45 |
Correct |
29 ms |
5208 KB |
n = 15 |
46 |
Correct |
53 ms |
11024 KB |
n = 16 |
47 |
Correct |
46 ms |
11100 KB |
n = 16 |
48 |
Correct |
54 ms |
11096 KB |
n = 16 |
49 |
Correct |
66 ms |
9664 KB |
n = 199999 |
50 |
Correct |
67 ms |
7760 KB |
n = 199991 |
51 |
Correct |
69 ms |
9412 KB |
n = 199993 |
52 |
Correct |
94 ms |
7528 KB |
n = 152076 |
53 |
Correct |
31 ms |
4044 KB |
n = 93249 |
54 |
Correct |
61 ms |
7872 KB |
n = 199910 |
55 |
Correct |
56 ms |
9028 KB |
n = 199999 |
56 |
Correct |
85 ms |
9544 KB |
n = 199997 |
57 |
Correct |
52 ms |
8564 KB |
n = 171294 |
58 |
Correct |
40 ms |
7372 KB |
n = 140872 |
59 |
Correct |
81 ms |
12228 KB |
n = 199886 |
60 |
Correct |
63 ms |
10940 KB |
n = 199996 |
61 |
Correct |
57 ms |
10436 KB |
n = 200000 |
62 |
Correct |
64 ms |
11064 KB |
n = 199998 |
63 |
Correct |
83 ms |
12728 KB |
n = 200000 |
64 |
Correct |
62 ms |
12228 KB |
n = 199998 |
65 |
Correct |
60 ms |
13624 KB |
n = 200000 |
66 |
Correct |
85 ms |
12120 KB |
n = 190000 |
67 |
Correct |
51 ms |
11204 KB |
n = 177777 |
68 |
Incorrect |
44 ms |
6096 KB |
answer is not correct: 1 instead of 0 |
69 |
Halted |
0 ms |
0 KB |
- |