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>
using namespace std;
using ll = long long;
#define all(x) x.begin(), x.end()
#define mp make_pair
#define mt make_tuple
#define x first
#define y second
#include "meetings.h"
vector<ll> minimum_costs(vector<int> h, vector<int> l, vector<int> r) {
int q = (int)l.size();
vector<ll> c(q);
for (int it = 0; it < q; ++it) {
int mn = l[it];
for (int i = l[it]; i <= r[it]; ++i) {
if (h[mn] > h[i]) {
mn = i;
}
}
ll ans = -h[mn];
int cur = h[mn];
for (int i = mn; i <= r[it]; ++i) {
cur = max(cur, h[i]);
ans += cur;
}
cur = h[mn];
for (int i = mn; i >= l[it]; --i) {
cur = max(cur, h[i]);
ans += cur;
}
c[it] = ans;
}
return c;
}
#ifdef LC
#include "grader.cpp"
#endif
# | 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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |