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 ll long long
#define ff first
#define ss second
#define pb push_back
#define mk make_pair
int l,r;
stack<pair<int,int> > pre,after;
vector<ll> ret;
std::vector<long long> minimum_costs(std::vector<int> H, std::vector<int> L,std::vector<int> R) {
int q = L.size();
for(int i = 0; i < q; i ++) {
l = L[i];
r = R[i];
ll ans = 1e18;
for(int j = l; j <= r; j ++) { // starting point
ll tmp = H[j];
ll mx = (ll) H[j];
for(int x = j - 1; x >= l ; x --) {
mx = max(mx, (ll) H[x]);
tmp += mx;
}
mx = H[j];
for(int x = j + 1; x <= r; x ++) {
mx = max(mx, (ll) H[x]);
tmp += mx;
}
ans = min(ans,tmp);
}
ret.pb(ans);
// while(pre.size() > 0) pre.pop();
// while(after.size() > 0) after.pop();
// ll cur = 0;
// for(int j = l; j <= r; j ++) {
// if(after.size() == 0) after.push({H[j],j}); // value / position
// else if(after.top().ff <= H[j]) after.push({H[j],j});
// cur += after.top().ff;
// }
// ll ans = cur;
// ret.pb(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... |