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 vi vector<int>
#define gi greater<int>
#define gr greater
#define ve vector
#define ll long long
#define vf vector<float>
#define vll vector<pair<ll,ll>>
#define ii pair<int,int>
#define pll pair<ll,ll>
#define vvi vector<vi>
#define vii vector<ii>
#define gii greater<ii>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define INF 1e9
#define eps 1e-7
#define eps1 1e-2
#define optimise ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MAX_A 2e5+5
using namespace std;
const int MOD = 1e9+7;
const int nax = 5005+5;
typedef complex<int> Point;
//#define X real()
//#define Y imag()
#include "meetings.h"
ll lft[nax][nax], rght[nax][nax];
ve<ll> minimum_costs(vi h, vi l, vi r) {
int n = h.size();
for (int i = 0; i < n; ++i)
{
int mx = h[i];
lft[i][i] = rght[i][i] = h[i];
for (int j = i-1; j >= 0; --j)
{
mx = max(mx,h[i]);
lft[i][j] += lft[i][j+1] + mx;
}
mx = h[i];
for (int j = i+1; j < n; ++j)
{
mx = max(mx,h[i]);
rght[i][j] += rght[i][j-1] + mx;
}
}
int q = l.size();
ve<ll> ans(q);
for (int j = 0; j < q; ++j)
{
ll mn = 0;
for (int i = l[j]; i <= r[j]; ++i)
{
ll ans = lft[i][l[j]] + rght[i][r[j]] - h[i];
mn = min(mn,ans);
}
ans[j] = mn;
}
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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |