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;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef long double ld;
typedef vector<vector<ll>> vll;
#define FOR(i, a, b) for(int i = a; i < b; i++)
#define ROF(i, a, b) for(int i = a; i >= b; i--)
#define pb push_back
#define ms memset
#define fi first
#define se second
vector<ll> minimum_costs(vi H, vi L, vi R) {
int n = H.size();
int q = R.size();
ll val[n][n]; ms(val,0,sizeof(val));
FOR(i,0,n){
val[i][i] = H[i];
int mx = H[i];
FOR(j,i+1,n){
mx = max(mx,H[j]);
val[i][j] = val[i][j-1] + mx;
}
mx=H[i];
ROF(j,i-1,0){
mx=max(mx,H[j]);
val[i][j] = val[i][j+1] + mx;
}
}
vector<ll> answer(q);
FOR(i,0,q){
answer[i] = 1e18;
FOR(j,L[i],R[i]+1){
answer[i]=min(answer[i],val[j][L[i]]+val[j][R[i]]-H[j]);
}
}
return answer;
}
# | 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... |