过了样例,WA 11pts
#include<bits/stdc++.h>
#define int long long
using namespace std;
inline int read() {int x=0,f=1; char ch=getchar();while(ch<'0'||ch>'9') { if(ch=='-') f=-1; ch=getchar();}while(ch>='0' && ch<='9') x=x*10+ch-'0',ch=getchar();return x*f;}
struct node{
int x,p,c;
} a[1000006];
int dp[1000006],n;
int sum(int l,int r){
int res=0;
for(int i=l;i<=r;i++){
res+=(a[i].x-a[l].x)*a[l].p;
}
return res;
}
signed main(){
memset(dp,0x3f3f3f3f,sizeof(dp));
n=read();
for(int i=1;i<=n;i++) a[i].x=read(),a[i].p=read(),a[i].c=read();
dp[1]=a[1].c;
for(int i=1;i<=n;i++){
for(int j=1;j<i;j++){
dp[i]=min(dp[i],dp[j]+sum(j+1,i)+a[i].c);
}
}
cout<<dp[n]<<endl;
return 0;
}