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>
#define vi vector<int>
#define ll long long
#define pb push_back
using namespace std;
const int tam=5005;
ll M[tam][tam];
vector<long long> minimum_costs(vector<int> H,vector<int> L,vector<int> R) {
int Q = L.size(),n=H.size();
vector<long long> C;
for(int i=0;i<n;i++){
int ma=0;
for(int l=i;l<n;l++){
ma=max(ma,H[l]);
M[i][l]=ma;
if(l>i)M[i][l]+=M[i][l-1];
}
ma=H[i];
for(int l=i-1;l>=0;l--){
ma=max(H[l],ma);
M[i][l]=ma;
if(l<i-1)M[i][l]+=M[i][l+1];
}
}
/*for(int i=0;i<n;i++){
for(int l=0;l<n;l++){
cout<<M[i][l]<<" ";
}
cout<<endl;
}*/
for(int i=0;i<Q;i++){
ll res=1e18;
for(int l=L[i];l<=R[i];l++){
ll B=M[l][R[i]];
ll A=0;
if(L[i]<l)A=M[l][L[i]];
res=min(res,A+B);
}
C.pb(res);
}
return C;
}
//4 2 2 4 3 5 0 2 1 3
# | 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... |