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 SIZE(x) int(x.size())
#define forn(i,n) for(int i=0;i<int(n);i++)
#define forsn(i,s,n) for(int i=int(s);i<int(n);i++)
#define dforn(i,n) for(int i=int(n)-1;i>=0;i--)
typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
const ll INF = 1e18;
vll minimum_costs(vi h, vi l, vi r) {
int q=SIZE(l), n=SIZE(h);
vll ans(q,INF);
forn(i,n) {
vi c(n);
c[i]=h[i];
dforn(j,i) c[j]=max(c[j+1],h[j]);
forsn(j,i+1,n) c[j]=max(c[j-1],h[j]);
vll p(n+1);
p[0]=0;
forn(j,n) p[j+1]=p[j]+c[j];
forn(j,q) ans[j]=min(ans[j],p[r[j]+1]-p[l[j]]);
}
return ans;
}
# | 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... |