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 q=L.size();
int n=H.size();
vector<ll> ans(q,1e18);
vector<vector<ll>> arr(n+1,vector<ll>(n+1));
for(int i=0;i<n;i++){
ll maxi=-1;
for(int c=i;c>=0;c--){
maxi=max(maxi, ll(H[c]));
arr[i][c]=arr[i][c+1]+maxi;
}
maxi=H[i];
for(int c=i+1;c<n;c++){
maxi=max(maxi, ll(H[c]));
arr[i][c]=arr[i][c-1]+maxi;
}
}
for(int i=0;i<q;i++){
for(int j=L[i];j<=R[i];j++) {
ans[i]=min(ans[i],arr[j][L[i]]+arr[j][R[i]]-H[j]);
}
}
return ans;
}
// void solve(){
// }
// int main(){
// ios::sync_with_stdio(false);cout.tie();cin.tie();
// int t=1;
// cin >> t;
// while(t--) solve();
// }
# | 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... |