Submission #422362

# Submission time Handle Problem Language Result Execution time Memory
422362 2021-06-10T04:46:08 Z TheWilp Roller Coaster Railroad (IOI16_railroad) C++14
0 / 100
104 ms 19204 KB
#include "railroad.h"
#include <vector>
#include <algorithm>
class name {
public:
    int value;
    int pos;
    bool operator<(const name& b) const {
        return value < b.value;
    }
} put_in;
std::vector<name> h;
std::vector<name> g;
bool check[100005];
long long plan_roller_coaster(std::vector<int> s, std::vector<int> t) {
    long long ans = 0;
    int N = (int) s.size();
    for (int q = 0; q < N; q++) {
        put_in.value = s[q];
        put_in.pos = q;
        h.push_back(put_in);
    }
    for (int q = 0; q < N; q++) {
        put_in.value = t[q];
        put_in.pos = q;
        g.push_back(put_in);
    }
    std::sort(h.begin(), h.end());
    std::sort(g.begin(), g.end());
    g.erase(g.end());
    for (int q = 0; q < N - 1; q++) {
        if (h.back().pos != g.back().pos) {
            if (h.back().value < g.back().value) {
                ans += g.back().value - h.back().value;
            }
            h.erase(h.end());
            g.erase(g.end());
        }
        else {
            if (h[h.size() - 2].value < g.back().value) {
                ans += g.back().value - h[h.size() - 2].value;
            }
            h.erase(h.end() - 1);
            g.erase(g.end());
        }
    }
    return ans;
}
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 460 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 460 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 104 ms 19204 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 460 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -