#include #include using namespace std; typedef long long LL; const int maxn=50005; struct COW { int w,s; }; int n; COW co[maxn]; inline bool operator<(const COW &a,const COW &b) { return a.w+a.sres) res=sum-co[i].s; sum+=co[i].w; } printf("%lld\n",res); return 0; }