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;
vector<ll> minimum_costs(vector<int> h,vector<int> l,vector<int> r) {
int n = l.size();
ll a = h.size();
vector<ll> c(n);
vector <vector<ll>> d(a,vector<ll>(a,0));
for (int z=0;z<a;z++){
ll maxi = h[z];
d[z][z] = h[z];
for (int x=z+1;x<a;x++){
maxi = max(maxi,ll(h[x]));
d[z][x] = d[z][x-1] + maxi;
}
maxi = h[z];
for (int x=z-1;x>-1;x--){
maxi = max(maxi,ll(h[x]));
d[z][x] = d[z][x+1] + maxi;
}
}
for (int z=0;z<n;z++){
ll left = l[z];
ll right = r[z];
c[z] = LLONG_MAX;
for (int x=left;x<=right;x++){
c[z] = min(c[z],d[x][right]+d[x][left]-ll(h[x]));
}
}
return c;
}
# | 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... |