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
const ll inf=1e18;
ll arr[105][105];
std::vector<long long> minimum_costs(std::vector<int> H, std::vector<int> L,
std::vector<int> R) {
ll n=H.size();
ll q=L.size();
vector<ll> ans;
for (int i=0;i<n;i++){
arr[i][i]=H[i];
for (int j=i-1;j>=0;j--){
arr[i][j]=max<ll>(arr[i][j+1],H[j]);
}
for (int j=i+1;j<n;j++){
arr[i][j]=max<ll>(arr[i][j-1],H[j]);
}
for (int j=1;j<n;j++){
arr[i][j]+=arr[i][j-1];
}
}
for (int i=0;i<q;i++){
ll tot=inf;
for (int j=L[i];j<=R[i];j++){
if (L[i]!=0) tot=min(tot,arr[j][R[i]]-arr[j][L[i]-1]);
else tot=min(tot,arr[j][R[i]]);
}
ans.emplace_back(tot);
}
return ans;
}
# | 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... |