# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
138963 | SirCeness | Roller Coaster Railroad (IOI16_railroad) | C++14 | 101 ms | 11112 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 "railroad.h"
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define inside sl<=l&&r<=sr
#define outside r<sl||sr<l
#define orta ((l+r)>>1)
#define INF 1000000009
#define mod 1000000007
#define ppair(x); cerr << "(" << x.first << ", " << x.second << ")\n";
#define bas(x) #x << ": " << x << " "
#define prarr(x, n); cerr << #x << ": "; for(int qsd = 0; qsd < n; qsd++) cerr << x[qsd] << " "; cerr << "\n";
#define prarrv(x); cerr << #x << ": "; for(int qsd = 0; qsd < (int)x.size(); qsd++) cerr << x[qsd] << " "; cerr << "\n";
using namespace std;
typedef long long ll;
struct node {
ll s, t;
bool operator<(const node& a){
return s+t > a.s + a.t;
}
};
long long plan_roller_coaster(vector<int> s, vector<int> t) {
int n = (int) s.size();
int smin = 0;
int minn = s[0];
for (int i = 0; i < s.size(); i++) if (s[i] < minn){
minn = s[i];
smin = i;
}
int tmax = 0;
int maxx = t[0];
for (int i = 0; i < t.size(); i++) if (t[i] > maxx){
maxx = t[i];
tmax = i;
}
vector<node> arr;
for (int i = 0; i < n; i++){
if (i != smin && i != tmax) arr.pb({s[i], t[i]});
}
sort(arr.begin(), arr.end());
arr.pb({s[tmax], t[tmax]});
ll ans = 0;
ll last = t[smin];
for (int i = 0; i < arr.size(); i++){
ans += max((ll)0, last - arr[i].s);
last = arr[i].t;
}
return ans;
}
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... |