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>
using namespace std;
using ll = long long;
int n;
ll plan_roller_coaster(vector<int> s, vector<int> t) {
n = (int)s.size();
vector<pair<int, int>> v;
for (int i = 0;i < n;i++) v.push_back({ s[i], t[i] });
sort(v.begin(), v.end(),
[&](pair<int, int> a, pair<int, int> b) {
if (a.second != b.second) return a.second < b.second;
return a.first < b.first;
}
);
int now = 1;
ll ans = 0;
for (int i = 0;i < n;i++) {
//cout << v[i].first << ' ' << v[i].second << '\n';
ans += max(0, now - v[i].first);
now = v[i].second;
}
return ans;
}
# | 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... |