1 #include<cstdio> 2 #include<algorithm> 3 #define MAXN 50010 4 using namespace std; 5 struct node 6 { 7 int w,h; 8 }st[MAXN]; 9 int main() 10 { 11 node temp; 12 int i,j,n,ans,top,wide; 13 while(scanf("%d",&n),n!=-1) 14 { 15 top=-1; 16 for(ans=i=0;i<n;i++) 17 { 18 scanf("%d%d",&temp.w,&temp.h); 19 for(wide=0;top>-1&&st[top].h>=temp.h;top--) 20 { 21 wide+=st[top].w; 22 ans=max(ans,st[top].h*wide); 23 } 24 temp.w+=wide; 25 st[++top]=temp; 26 } 27 for(wide=0;top>-1;top--) 28 { 29 wide+=st[top].w; 30 ans=max(ans,st[top].h*wide); 31 } 32 printf("%d\n",ans); 33 } 34 return 0; 35 }