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
vector<long long> minimum_costs(vector<int> H, vector<int> L,vector<int> R) {
int q = L.size();
int n = H.size();
vector<ll> ans(q);
vector<vector<ll>> mn(n,vector<ll>(n,1e18));
for(int i = 0; i < n; i++){
mn[i][i] = H[i];
int curr = H[i];
for(int j = i-1; j >= 0; j--){
curr = min(curr,H[j]);
mn[j][i] = curr;
}curr = H[i];
for(int j = i+1; j < n; j++){
curr = min(curr,H[j]);
mn[j][i] = curr;
}
}
for(int i = 0; i < n; i++){
for(int j = 1; j < n; j++){
mn[j][i] += mn[j-1][i];
}
}
for(int v = 0; v < q; v++){
int l = L[v];
int r = R[v];
ll cnt = 1e18;
for(int i = l; i <= r; i++){
if(l == 0)cnt = min(cnt,mn[r][i]);
else cnt = min(cnt,mn[r][i]-mn[l-1][i]);
}
ans[v] = cnt;
}
return ans;
}
// int main(){
// }
# | 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... |