标签:lines 宽度 char one play efi void cep body
Time Limit: 1000MS | Memory Limit: 30000K | |
Total Submissions: 5067 | Accepted: 2593 |
Description
Input
Output
Sample Input
3 1 2 3 4 1 2 3 3 4 1 2 3 4 -1
Sample Output
12 14
Source
1 #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4 #include <cstdlib> 5 #define max(a, b) ((a) < (b) ? (b) : (a)) 6 7 const int MAXN = 60000 + 10; 8 9 inline void read(int &x) 10 { 11 x = 0;char ch = getchar(), c = ch; 12 while(ch < ‘0‘ || ch > ‘9‘)c = ch, ch = getchar(); 13 while(ch <= ‘9‘ && ch >= ‘0‘)x = x * 10 + ch - ‘0‘, ch = getchar(); 14 if(c == ‘-‘)x = -x; 15 } 16 17 int n,w,h,stackw[MAXN],stackh[MAXN],top,ans; 18 19 int main() 20 { 21 while(scanf("%d", &n) != EOF && n != -1) 22 { 23 read(stackw[++top]), read(stackh[top]); 24 ans = stackw[top] * stackh[top]; 25 register int lei = 0; 26 for(register int i = 2;i <= n;++ i) 27 { 28 read(w), read(h); 29 ans = max(ans, w * h); 30 if(h < stackh[top]) 31 { 32 lei = 0; 33 while(h < stackh[top]) 34 { 35 lei += stackw[top]; 36 ans = max(ans, lei * stackh[top]); 37 -- top; 38 } 39 stackh[++top] = h; 40 stackw[top] = lei; 41 } 42 stackh[++top] = h; 43 stackw[top] = w; 44 } 45 lei = 0; 46 while(top) 47 { 48 lei += stackw[top]; 49 ans = max(ans, lei * stackh[top]); 50 -- top; 51 } 52 printf("%d\n", ans); 53 } 54 return 0; 55 }
标签:lines 宽度 char one play efi void cep body
原文地址:http://www.cnblogs.com/huibixiaoxing/p/7469232.html