题目:http://codeforces.com/contest/237/problem/A
那么简单的题目,还是忘了考虑n = 1时的情况了。。。
View Code
1 typedef long long ll; 2 const int N = 100001; 3 char str[N][10]; 4 int main() 5 { 6 int n; 7 int i; 8 while(~scanf("%d",&n)) 9 { 10 getchar(); 11 for(i = 0; i < n; i++) 12 { 13 gets(str[i]); 14 //cout<<"str[i] = "<<str[i]<<"***\n"; 15 } 16 if(n == 1) 17 { 18 printf("1\n"); 19 continue; 20 } 21 int maxx = -1; 22 i = 1; 23 int sum; 24 while(i < n) 25 { 26 if(!strcmp(str[i],str[i - 1])) sum = 1; 27 else sum = 0; 28 while(!strcmp(str[i],str[i - 1])) 29 { 30 sum ++; 31 i++; 32 } 33 if(sum > maxx) maxx = sum; 34 i++; 35 } 36 if(!maxx) maxx = 1; 37 printf("%d\n",maxx); 38 } 39 return 0; 40 }