#include #include #include using namespace std; int T,n; struct node{ int x,y; bool operator <(const node b)const{return x=1; j--) for (int k=1; k<=p[j].y; k++){ cnt+=p[j].x; if (cnt>=0) ans+=cnt; } printf("%lld\n",ans); } return 0; }