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 "meetings.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll linf = ll(1e18);
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> p2;
#define rep(i, high) for (int i = 0; i < high; i++)
#define repp(i, low, high) for (int i = low; i < high; i++)
#define repe(i, container) for (auto& i : container)
#define sz(container) ((int)container.size())
#define all(x) begin(x),end(x)
#if _LOCAL
#define assert(x) if (!(x)) __debugbreak()
#endif
typedef vector<ll> vll;
vll minimum_costs(vi H, std::vector<int> l, std::vector<int> r)
{
vll h(H.begin(), H.end());
int q = sz(l);
vll ret(q);
rep(qu, q)
{
ll ans = linf;
repp(i, l[qu], r[qu] + 1)
{
ll cost = h[i];
ll la = h[i];
repp(j, i+1, r[qu]+1)
{
la = max(la, h[j]);
cost += la;
}
la = h[i];
for (int j = i-1; j >= l[qu]; j--)
{
la = max(la, h[j]);
cost += la;
}
ans = min(ans, cost);
}
ret[qu] = ans;
}
return ret;
}
# | 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... |