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;
std::vector<long long> minimum_costs(std::vector<int> H, std::vector<int> L,
std::vector<int> R) {
int Q = L.size();
std::vector<long long> C(Q);
int n = H.size();
long long sum[n][n]; memset(sum,0,sizeof sum);
for(int i = 0; i<n; i++){
int mx = H[i];
for(int j = i; j>=0; j--){
mx = max(mx,H[j]);
if(j<i)
sum[i][j]= sum[i][j+1]+mx;
else sum[i][j] = mx;
}
mx = H[i];
for(int j = i+1; j<n; j++){
mx = max(mx,H[j]);
if(j>i+1)
sum[i][j] = sum[i][j-1]+mx;
else sum[i][j] = mx;
}
}
for (int j = 0; j < Q; ++j) {
long long res = LLONG_MAX;
for(int i = L[j]; i<=R[j]; i++) res = min(res,sum[i][L[j]]+sum[i][R[j]]);
C[j] = res;
}
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... |