标签:
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 5305 Accepted Submission(s):
1817
1 #include <cstdlib> 2 #include <cstdio> 3 #include <iostream> 4 5 using namespace std; 6 7 int main(int argc, char *argv[]) 8 { 9 int n, a, b; 10 while (scanf("%d", &n)!=EOF) 11 { 12 int i, j, res[100000], max=0, count=0,flag=0, temp=0; 13 for (i=0; i<n; i++) 14 { 15 scanf("%d%d", &a, &b); 16 res[i] = a - b; 17 temp += res[i]; 18 if (temp >= 0) 19 count++; 20 else 21 { 22 count = 0; 23 temp = 0; 24 } 25 if (count > max) 26 max = count; 27 } 28 for(i=0;i<n;i++) 29 { 30 temp += res[i]; 31 if (temp >= 0) 32 count++; 33 else 34 { 35 count = 0; 36 temp = 0; 37 } 38 if (count > max) 39 max = count; 40 } 41 printf("%d\n", max>n?n:max); 42 } 43 // system("PAUSE"); 44 return 0; 45 }
标签:
原文地址:http://www.cnblogs.com/a1225234/p/4622254.html