This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
///~~~LOTA~~~///
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define append push_back
#define add insert
#define nl '\n'
#define ff first
#define ss second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define all(x) (x).begin(),(x).end()
#define L0TA ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define terminator main
#define N 90000
vector<ll> minimum_costs(vector<int> a,vector<int> l,vector<int> r){
int n,m,o;
n=a.size();
m=l.size();
ll pre[n][n];
ll suf[n][n];
for(int i=0;i<n;i++){
pre[i][i]=o=a[i];
suf[i][i]=0;
for(int j=i-1;j>=0;j--){
o=max(o,a[j]);
pre[i][j]=pre[i][j+1]+o;
}
o=a[i];
for(int j=i+1;j<n;j++){
o=max(o,a[j]);
suf[i][j]=suf[i][j-1]+o;
}
}
ll x;
vector<ll> ans;
for(int i=0;i<m;i++){
x=1e18;
for(int j=l[i];j<=r[i];j++)
x=min(x,pre[j][l[i]]+suf[j][r[i]]);
ans.append(x);
}
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... |