设为首页 加入收藏

TOP

POJ2456 Aggressive cows(二分+贪心)
2015-07-20 17:29:22 来源: 作者: 【 】 浏览:5
Tags:POJ2456 Aggressive cows (二分 贪心

假设C(d)为满足所有牛之间的距离都不小于d。先对牛舍的位置排序,然后二分枚举d,寻找满足条件的d。

#include
  
   
#include
   
     #include
    
      #include
     
       #include
      
        #include
       
         #include
        
          #include
          #include
          
            #include
           
             #define ll __int64 #define INF 0x3fffffff using namespace std; int n,m; int x[100005]; bool C(int d) { int num=1; int a=x[0]; int i=1; while(num
            
             1) { int mid=(r+l)/2; if(C(mid)) l=mid; else r=mid; } cout<
             
              >n>>m; for(int i=0;i
              
               

】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇OO模式-Composite 下一篇UVA 10910 Marks Distribution(..

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

·About - Redis (2025-12-26 08:20:56)
·Redis: A Comprehens (2025-12-26 08:20:53)
·Redis - The Real-ti (2025-12-26 08:20:50)
·Bash 脚本教程——Li (2025-12-26 07:53:35)
·实战篇!Linux shell (2025-12-26 07:53:32)