# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1042360 | baldwinhuang1 | Roller Coaster Railroad (IOI16_railroad) | C++14 | 28 ms | 10184 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
long long plan_roller_coaster(vector<int> s, vector<int> t) {
vector< pair<int, int> > st;
if (s.size() <= 8) {
for (int i = 0; i < s.size(); i++) {
st.push_back({s[i], t[i]});
// cout << s[i] << '-' << t[i] << '\n';
}
sort(st.begin(), st.end());
long long minimo = 1e18;
do {
long long count = 0;
for (int i = 0; i < (s.size() - 1); i++) {
if (st[i].second > st[i + 1].first) {
count += (st[i].second - st[i + 1].first);
}
}
// if (count == 0) {
// for (auto &i: st) {
// cout << i.first << '-' << i.second << ' ';
// }
// cout << '\n';
// }
minimo = min(minimo, count);
} while (next_permutation(st.begin(), st.end()));
return minimo;
}
for (int i = 0; i < s.size(); i++) {
st.push_back({s[i], t[i]});
// cout << s[i] << '-' << t[i] << '\n';
}
sort(st.begin(), st.end(), [](pair<int, int> i, pair<int, int> j){return i.second <= j.first;});
bool state = true;
for (int i = 0; i < (st.size() - 1); i++) {
if (st[i].second > st[i + 1].first) {
state = false;
}
}
// for (auto &i: st) {
// cout << i.first << '-' << i.second << ' ';
// }
// cout << '\n';
return state;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |