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"
#ifndef EVAL
#include "grader.cpp"
#endif // EVAL
#include <bits/stdc++.h>
using namespace std;
#define lol long long
#define pii pair<int,int>
#define OK puts("OK");
#define NO puts("NO");
#define YES puts("YES");
#define fr first
#define sc second
#define ret return
#define scanl(a) scanf("%lld",&a);
#define scanll(a,b) scanf("%lld %lld",&a, &b);
#define scanlll(a,b,c) scanf("%lld %lld %lld",&a,&b,&c);
#define scan1(a) scanf("%d",&a);
#define scan2(a,b) scanf("%d %d",&a, &b);
#define scan3(a,b,c) scanf("%d %d %d",&a,&b,&c);
#define all(s) s.begin(),s.end()
#define allr(s) s.rbegin(),s.rend()
#define pb push_back
#define sz(v) (int)v.size()
#define endi puts("");
#define eps 1e-12
lol dis[5001][5001],mx[5001][5001];
vector<lol> minimum_costs(vector<int> H, vector<int> L,vector<int> R) {
int i,j,k,n = H.size(),Q = L.size();
vector<lol> C(Q);
for (i=0;i<n;++i){
lol mx = 0,ans=0;
for (k=i;k>=0;--k){
mx = max(mx,H[k]*1ll);
ans += mx;
dis[i][k] = ans;
}
mx = H[i];
ans = 0;
for (k=i+1;k<n;++k){
mx = max(mx,H[k]*1ll);
ans += mx;
dis[i][k] = ans;
}
}
for (j = 0; j < Q; ++j){
C[j] = 1e15+7;
for (i=L[j];i<R[j];++i){
C[j] = min(C[j],dis[i][L[j]] + dis[i][R[j]]);
}
}
ret 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... |