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 pair<int, int> ii;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<ii> vii;
#define REP(a,b,c) for(int a=int(b); a<int(c); a++)
#define REV(a,b,c) for(int a=int(c-1); a>=int(b); a--)
#define RE(a,b) REP(a,0,b)
#define RE1(a,b) REP(a,1,b+1)
#define FOR(a,b) for(auto& a : b)
#define pb push_back
#define fi first
#define se second
#define all(a) a.begin(), a.end()
vll minimum_costs(vi H, vi L, vi R) {
int n = H.size();
int q = L.size();
vector<vll> costL, costR;
RE(i,2) (i?costL:costR).assign(n,vll(n,0));
RE(i,n) {
ll mx = 0;
ll res = 0;
REP(j,i,n) {
mx = max<ll>(mx,H[j]);
res += mx;
costL[i][j] = res;
}
mx = res = 0;
REV(j,0,i+1) {
mx = max<ll>(mx,H[j]);
res += mx;
costR[i][j] = res;
}
}
vll C(q,1e18);
RE(cq,q) {
int l=L[cq], r=R[cq];
REP(i,l,r+1) {
C[cq] = min(C[cq], costR[i][l] + costL[i][r] - H[i]);
}
}
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... |