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
#define ff first
#define ss second
#define all(a) (a).begin(), (a).end()
template<typename T>
int len(T &a){
return a.size();
}
const ll infl = 1e18 + 110;
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
vector<long long> minimum_costs(vector<int> h, vector<int> L,
vector<int> R) {
int n = len(h);
int q = len(L);
vector<vector<ll>> cost(n, vector<ll> (n, 0));
for(int i = 0; i < n; i ++){
int mx = 0;
for(int j = i; j >= 0; j --){
mx = max(mx, h[j]);
cost[i][j] = mx;
}
mx = 0;
for(int j = i; j < n; j ++){
mx = max(mx, h[j]);
cost[i][j] = mx;
}
for(int j = 1; j < n; j ++){
cost[i][j] += cost[i][j - 1];
}
}
vector<ll> res(q, infl);
for(int i = 0; i < q; i ++){
for(int j = L[i]; j <= R[i]; j ++){
res[i] = min(res[i], cost[j][R[i]] - (L[i] ? cost[j][L[i] - 1] : 0));
}
}
return res;
}
# | 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... |