# 洛谷2120 [ZJOI2007]仓库建设（斜率优化dp）

qwq不想多说了

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#define mk make_pair
#define ll long long
#define int long long
using namespace std;
{
int x=0,f=1;char ch=getchar();
while (!isdigit(ch)) {if (ch=='-') f=-1;ch=getchar();}
while (isdigit(ch)) {x=(x<<1)+(x<<3)+ch-'0';ch=getchar();}
return x*f;
}
const int maxn = 1e6+1e2;
int n,m;
int w[maxn],d[maxn];
int f[maxn];
int dis[maxn],val[maxn],sum[maxn];
int sw[maxn];
struct Point{
int x,y,num;
};
Point q[maxn];
int chacheng(Point x,Point y)
{
return x.x*y.y-x.y*y.x;
}
bool count(Point i,Point j,Point k)
{
Point x,y;
x.x=k.x-i.x;
x.y=k.y-i.y;
y.x=k.x-j.x;
y.y=k.y-j.y;
if (chacheng(x,y)<=0) return true;
return false;

void push(Point x)
{
q[++tail]=x;
}
void pop(int lim)
{
}
int g[maxn];
int ymh[maxn];
signed main()
{
for (int i=1;i<=n;i++) dis[i]=d[n]-d[i];
for (int i=1;i<=n;i++) sw[i]=sw[i-1]+w[i];
for (int i=1;i<=n;i++) val[i]=w[i]*dis[i];
for (int i=1;i<=n;i++) sum[i]=sum[i-1]+val[i];
g[0]=sum[n];
push((Point){0,sum[n],0});
for (int i=1;i<=n;i++)
{
pop((-1)*dis[i]);