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;
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...)
#endif
long long plan_roller_coaster(vector<int> s, vector<int> t) {
    s.emplace_back((int) 1e9);
    t.emplace_back(1);
    int n = (int) s.size();
    multiset<pair<int, int>> st, ts;
    for (int i = 0; i < n; i++) {
        st.emplace(s[i], t[i]);
        ts.emplace(t[i], s[i]);
    }
    while (st.size() > 1) {
        auto p = *ts.rbegin();
        ts.erase(ts.find(p));
        swap(p.first, p.second);
        st.erase(st.find(p));
        auto q = *st.rbegin();
        swap(q.first, q.second);
        ts.erase(ts.find(q));
        swap(q.first, q.second);
        st.erase(st.find(q));
        if (p.second > q.first) {
            return 1;
        }
        st.emplace(p.first, q.second);
        ts.emplace(q.second, p.first);
    }
    auto p = *st.begin();
    if (p.first < p.second) {
        return 1;
    } else {
        return 0;
    }
}
#ifdef tabr
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    debug(plan_roller_coaster({1, 4, 5, 6}, {7, 3, 8, 6}));
    return 0;
}
#endif
| # | 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... |