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 <bits/stdc++.h>
# include "meetings.h"
using namespace std;
const int N = 8e5 + 2;
const int M = 5e3 + 2;
long long a[M][M];
vector<long long> minimum_costs(vector<int> H, vector<int> L, vector<int> R) {
int Q = L.size();
int n = H.size();
vector<long long> C(Q);
if(n <= 5000){
for(int i = 0; i < n; i ++){
a[i][i] = H[i];
for(int j = i - 1; j >= 0; j --)
a[i][j] = max(int(a[i][j + 1]), H[j]);
for(int j = i + 1; j < n; j ++)
a[i][j] = max(int(a[i][j - 1]), H[j]);
for(int j = 1; j < n; j ++)
a[i][j] += a[i][j - 1];
}
for(int i = 0; i < Q; i ++){
long long ret = 5e18;
for(int j = L[i]; j <= R[i]; j ++){
long long now = a[j][R[i]];
if(L[i])
now -= a[j][L[i] - 1];
ret = min(ret, now);
}
C[i] = ret;
}
} else {
}
return C;
}
# | 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... |