hdu 1800 Flying to the Mars (map)(暴力)

2015-07-20 18:00:59 · 作者: · 浏览: 4

map


//输入一堆数字 看一堆数中最少有多少个上升子串(不连续的子串)
//每个串去掉一串最长的 再去掉一串次长的。
//到最后肯定剩下某个出现次数最多的数字? 
//所以本题就是找那个数字出现的最多  最多的次数是多少
//因为数太大数组存不下 所以用map
# include
  
   
# include
    # include
    
      # include 
     
       using namespace std; int main() { int n; __int64 a,max; map<__int64,__int64>q; while(~scanf("%d",&n)) { q.clear(); while(n--) { scanf("%I64d",&a); q[a]++; } map<__int64,__int64>::iterator it; max=0; //it->first 为a,it->second为 q[]++; //iterator->first 关键字(key) //iterator->second 存储的数据(value) for(it=q.begin();it!=q.end();it++) { if(max
      
       second) max=it->second; } printf("%I64d\n",max); } return 0; }
      
     
    
  


暴力


# include 
  
   
# include 
   
     # include 
    
      using namespace std; int main() { int a[3010],flag[3010]; int n,i,min,cot,count; while(~scanf("%d",&n)) { for(i=0;i
     
      min) { min=a[i]; flag[i]=1; count++; } } if(count==n) { printf("%d\n",cot); break; } } } return 0; }