--hdu 1800 Flying to the Mars(贪心)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1800
Ac code:
#include<stdio.h> #include<stdlib.h> int cmp(const void *a,const void *b) { return *(int *)a-*(int *)b; } int main(void) { int n,i,ma,t; int a[3005]; while(scanf("%d",&n)!=EOF) { for(i=0;i<n;i++) { scanf("%d",&a[i]); } qsort(a,n,sizeof(a[0]),cmp); ma=1;t=1; for(i=1;i<n;++i) { if(a[i]!=a[i-1]) t=1; else ++t; ma=t>ma?t:ma; } printf("%d\n",ma); } return 0; }