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;
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef complex<double> cd;
const ll LINF = 0x3f3f3f3f3f3f3f3f;
vector<long long> minimum_costs(vector<int> H, vector<int> L, vector<int> R) {
int q=(int)L.size(), n=(int)H.size();
vector<ll> ans(q);
vector<vector<ll>> res(n, vector<ll>(n));
for(int i=0;i<n;i++){
res[i][i]=H[i];
int curr=H[i];
for(int j=i+1;j<n;j++){
curr=max(curr, H[j]);
res[i][j]=res[i][j-1]+curr;
}
curr=H[i];
for(int j=i-1;j>=0;j--){
curr=max(curr, H[j]);
res[i][j]=res[i][j+1]+curr;
}
}
for(int i=0;i<q;i++){
ll best=LINF;
for(int j=L[i];j<=R[i];j++) best=min(best, res[j][L[i]]+res[j][R[i]]-H[j]);
ans[i]=best;
}
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... |