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;
vector<long long> minimum_costs(vector<int> H, vector<int> L,
vector<int> R) {
int Q = L.size();
vector<long long> C(Q);
auto mx = [&](int l,int r){
int res = 0;
for(int i=l;i<=r;i++)res = max(res,H[i]);
return res;
};
auto choose = [&](int ind,int l,int r){
long long res = 0;
for(int i=l;i<=r;i++){
if(i <= ind)res += mx(i,ind);
else res += mx(ind,i);
}
return res;
};
for(int i=0;i<Q;i++){
int l = L[i], r = R[i];
long long ans =1e18;
//cerr<<i<<": ";
for(int j=l;j<=r;j++){
ans = min(ans,choose(j,l,r));
//cerr<<j<<" "<<ans<<'\n';
}
C[i] = ans;
}
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... |