Submission #1073926

# Submission time Handle Problem Language Result Execution time Memory
1073926 2024-08-25T03:48:42 Z skittles1412 Roller Coaster Railroad (IOI16_railroad) C++17
0 / 100
239 ms 27588 KB
#include "bits/extc++.h"

using namespace std;

template <typename T, typename... U>
void dbgh(const T& t, const U&... u) {
    cerr << t;
    ((cerr << " | " << u), ...);
    cerr << endl;
}

#ifdef DEBUG
#define dbg(...)                                              \
    cerr << "L" << __LINE__ << " [" << #__VA_ARGS__ << "]: "; \
    dbgh(__VA_ARGS__)
#else
#define dbg(...)
#define cerr   \
    if (false) \
    cerr
#endif

using ll = long long;

#define endl "\n"
#define long int64_t
#define sz(x) int(std::size(x))

inline void init_io() {
    cin.tie(nullptr);
    cin.exceptions(ios::failbit);
    ios_base::sync_with_stdio(false);
}

template <typename T>
ostream& operator<<(ostream& out, const vector<T>& arr) {
    out << "[";
    for (int i = 0; i < sz(arr); i++) {
        if (i) {
            out << ", ";
        }
        out << arr[i];
    }
    return out << "]";
}

template <typename T>
struct PSA {
    int n;
    vector<T> psum;

    template <typename U>
    PSA(const vector<U>& arr) : n(sz(arr)), psum(n + 1) {
        for (int i = 0; i < n; i++) {
            psum[i + 1] = psum[i] + arr[i];
        }
    }

    T query(int l, int r) const {
        return psum[r] - psum[l];
    }
};

template <typename T>
bool on(T mask, int bit) {
    return (mask >> bit) & 1;
}

template <typename T>
vector<T> iota(int n, T x) {
    vector<T> arr(n);
    iota(begin(arr), end(arr), x);
    return arr;
}

template <typename T>
T reversed(T arr) {
    reverse(begin(arr), end(arr));
    return arr;
}

template <typename A, typename B>
ostream& operator<<(ostream& out, const pair<A, B>& p) {
    return out << "(" << p.first << ", " << p.second << ")";
}

long solve(const vector<pair<int, int>>& arr) {
    dbg(arr);
    map<int, int, greater<>> cnt;

    for (auto& [a, b] : arr) {
        cnt[a]++;
        cnt[b]--;
    }

    int pref = 0;
    for (auto& [_t, v] : cnt) {
        pref += v;
        if (pref < 0) {
            return 1;
        }
    }
    return 0;
}

ll plan_roller_coaster(vector<int> s, vector<int> t) {
    vector<pair<int, int>> ans;

    for (int i = 0; i < sz(s); i++) {
        ans.emplace_back(s[i], t[i]);
    }

    return solve(ans);
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB n = 2
2 Correct 0 ms 348 KB n = 2
3 Correct 0 ms 348 KB n = 2
4 Correct 1 ms 344 KB n = 2
5 Correct 0 ms 348 KB n = 2
6 Incorrect 1 ms 348 KB answer is not correct: 1 instead of 523688153
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB n = 2
2 Correct 0 ms 348 KB n = 2
3 Correct 0 ms 348 KB n = 2
4 Correct 1 ms 344 KB n = 2
5 Correct 0 ms 348 KB n = 2
6 Incorrect 1 ms 348 KB answer is not correct: 1 instead of 523688153
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 239 ms 27588 KB n = 199999
2 Correct 196 ms 27584 KB n = 199991
3 Correct 218 ms 27580 KB n = 199993
4 Correct 146 ms 20700 KB n = 152076
5 Correct 76 ms 13000 KB n = 93249
6 Correct 171 ms 23076 KB n = 199910
7 Correct 162 ms 26524 KB n = 199999
8 Correct 151 ms 23236 KB n = 199997
9 Correct 176 ms 23488 KB n = 171294
10 Incorrect 119 ms 19492 KB answer is not correct: 1 instead of 0
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB n = 2
2 Correct 0 ms 348 KB n = 2
3 Correct 0 ms 348 KB n = 2
4 Correct 1 ms 344 KB n = 2
5 Correct 0 ms 348 KB n = 2
6 Incorrect 1 ms 348 KB answer is not correct: 1 instead of 523688153
7 Halted 0 ms 0 KB -