# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
827525 | caganyanmaz | Roller Coaster Railroad (IOI16_railroad) | C++14 | 82 ms | 15648 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>
#define mp(x...) array<int, 2>({x})
#define pb push_back
#define int int64_t
#include "railroad.h"
using namespace std;
#ifdef DEBUGGING
#include "../debug.h"
#else
#define debug(x...) void(42)
#endif
long long plan_roller_coaster(vector<int32_t> s, vector<int32_t> t)
{
int n = s.size();
vector<array<int, 2>> vals;
for (int i = 0; i < n; i++)
{
vals.pb({s[i], +1});
vals.pb({t[i], -1});
}
sort(vals.begin(), vals.end());
int pf = vals[0][1] - 1;
int res = 0;
for (int i = 1; i < vals.size(); i++)
{
debug(pf, vals[i-1][0], vals[i][0]);
if ((pf == 0 && vals[i-1][0] != vals[0][0] && vals[i][0] != vals.back()[0]) || pf > 0)
res += max<int>(pf, 1) * (vals[i][0] - vals[i-1][0]);
pf += vals[i][1];
}
return res;
}
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... |