我们按x排序 , 如果被包涵就直接剔除这个点
显然取一段连续的是最优的 , 因此定义f[i] 表示1--i 的最小价值
斜率优化搞一波 , 树形结合来写
#include<bits/stdc++.h>
#define N 50050
#define LL long long
using namespace std;
LL f[N],n,tot,Max,q[N];
struct Node{LL x,y;}a[N],b[N];
bool cmp(Node a,Node b){
if(a.x==b.x) return a.y<b.y;
return a.x<b.x;}
double K(LL i,LL j){
return (f[j]-f[i])*1.0 / (a[j+1].y-a[i+1].y)*1.0;
}
int main(){
scanf("%d",&n);
for(int i=1;i<=n;i++){
scanf("%d%d",&b[i].x,&b[i].y);
} sort(b+1,b+n+1,cmp);
for(int i=n;i>=1;i--) if(b[i].y>Max){
a[++tot] = b[i]; Max = b[i].y;
} sort(a+1,a+tot+1,cmp);
// f[i] = min(f[j] + a[j+1].y*a[i].x)
// b -> f[i] , y -> f[j] , k -> -a[i].x , x -> a[j+1].y
int l=1,r=0; q[++r]=0;
for(int i=1;i<=tot;i++){
while(l<r && K(q[l],q[l+1]) >= -a[i].x) l++;
f[i] = f[q[l]] + a[q[l]+1].y * a[i].x;
while(l<r && K(q[r],i) >= K(q[r-1],q[r])) r--;
q[++r] = i;
} printf("%lld",f[tot]); return 0;
}