Kayaking Trip

时间限制: 1 Sec  内存限制: 128 MB
提交: 95  解决: 34
[提交] [状态] [讨论版] [命题人:admin]

题目描述

You are leading a kayaking trip with a mixed group of participants in the Stockholm archipelago, but as you are about to begin your final stretch back to the mainland you notice a storm on the horizon. You had better paddle as fast as you can to make sure you do not get trapped on one of the islands. Of course, you cannot leave anyone behind, so your speed will be determined by the slowest kayak. 
Time to start thinking; How should you distribute the participants among the kayaks to maximize your chance of reaching the mainland safely?
The kayaks are of different types and have different amounts of packing, so some are more easily paddled than others. This is captured by a speed factor c that you have already figured out for each kayak. The final speed v of a kayak, however, is also determined by the strengths s1 and s2 of the two people in the kayak, by the relation v = c(s1 + s2 ). In your group you have some beginners with a kayaking strength of sb , a number of normal participants with strength s n and some quite experienced strong kayakers with strength se .

输入

The first line of input contains three non-negative integers b, n, and e, denoting the number of beginners, normal  participants, and experienced kayakers, respectively. The total number of participants, b + n + e, will be even, at least 2, and no more than 100 000. This is followed by a line with three integers sb , sn , and se , giving the strengths of the corresponding participants (1 ≤ sb < sn < se ≤ 1 000). The third and final line contains m = (b+n+e)/2 integers c1 , . . . , cm(1 ≤ ci ≤ 100 000 for each i), each giving the speed factor of one kayak.

输出

Output a single integer, the maximum speed that the slowest kayak can get by distributing the participants two in each kayak.

样例输入

3 1 0
40 60 90
18 20

样例输出

1600

[思路]

求最小中最大,   所以要用 二分.

V = C(s1+s2)

已知C 组合s1,s2   二分答案 V  ,然后 贪心 组合 (s1,s2) 判断 是否满足  (注意存在个数限制)

[代码]

#include <bits/stdc++.h>
#include <stdio.h>
#define rep(i,a,n) for(int i=1;i<=n;i++)
/*
*
*  Author : siz*/
using namespace std;
typedef long long ll;
const int maxn =1e5+10;
const int mod =1e9+7;
const double esp =1e-6;
int b,n,e;
int sb,sn,se;
int c[maxn];
int m;
struct node
{int b,n,e,sum;node(){}node(int bb,int nn,int ee,int Sum){b = bb,n = nn,e = ee,sum = Sum;}friend bool operator < (const node a,const node b){return a.sum < b.sum;}
}Node[20];
bool judge(int mid)
{int bb = b,nn = n,ee = e;rep(i,1,m){double Ss = ( (mid*1.0)/(1.0*c[i]));   int cot = 0;if( bb >= 2)Node[++cot] = node{2,0,0,sb+sb};if( nn >= 2)Node[++cot] = node{0,2,0,sn+sn};   if( ee >= 2)Node[++cot] = node{0,0,2,se+se};if( bb&&nn )Node[++cot] = node{1,1,0,sb+sn};    if( bb&&ee )Node[++cot] = node{1,0,1,sb+se};    if( nn&&ee )Node[++cot] = node{0,1,1,sn+se};    sort(Node+1,Node+cot+1);int flag = false;rep(j,1,cot){if( (Ss - (double)Node[j].sum) < esp){flag = true;bb -= Node[j].b;nn -= Node[j].n;ee -= Node[j].e;break;}}if(!flag)return false;}return true;
}
int main()
{scanf("%d %d %d",&b,&n,&e);m = (b+n+e)/2;scanf("%d %d %d",&sb,&sn,&se);rep(i,1,m) scanf("%d",&c[i]);sort(c+1,c+m+1);int l = 1 , r = 1000000000;int ans  = 0 ;while( l <= r){int mid = (l+r)>>1;if(judge(mid)){ans = mid;l = mid+1;}elser = mid -1;}//cout<<ans<<" "<<l<<" "<<r<<endl;printf("%d\n",ans);return 0;
}

@2017-2018 ACM-ICPC Nordic Collegiate Programming Contest (NCPC 2017) K:Kayaking Trip(二分+贪心)相关推荐

  1. 2017-2018 ACM-ICPC Nordic Collegiate Programming Contest (NCPC 2017)

    D.Distinctive Character 看到样例,第一个反应贪心.先写了个按这一位1和0的数目多少,确定0还是1的东西.感觉不够真,又写了个尽量加到相似的比较小的串上的贪心.在和前边的那个组合 ...

  2. 2018 ACM ICPC Arabella Collegiate Programming Contest A

    Multiplication operation is not always easy! For example, it is hard to calculate 27 × 20 using your ...

  3. A - Multiplication Dilemma (思维)( 2018 ACM ICPC Arabella Collegiate Programming Contest)

    滴答滴答---题目链接 Multiplication operation is not always easy! For example, it is hard to calculate 27 × 2 ...

  4. 2016-2017 ACM-ICPC Nordic Collegiate Programming Contest (NCPC 2016)题解

    2016-2017 ACM-ICPC Nordic Collegiate Programming Contest (NCPC 2016) A - Artwork 题目描述: 给定N*M的网格,给出Q次 ...

  5. 2018-2019 ACM-ICPC Nordic Collegiate Programming Contest (NCPC 2018) - 4.28

    赛后补了几道 赛中我就写了两个... A - Altruistic AmphibiansGym - 101933A 看了眼榜没几个人做.就没看. 最后发现就是一个DP(但是我觉得复杂度有点迷) 题意: ...

  6. Nordic Collegiate Programming Contest (NCPC) 2016

    A Artwork B Bless You Autocorrect! C Card Hand Sorting D Daydreaming Stockbroker 贪心,低买高卖,不要爆int. #in ...

  7. (寒假开黑gym)2017-2018 ACM-ICPC German Collegiate Programming Contest (GCPC 2017)

    layout: post title: (寒假开黑gym)2017-2018 ACM-ICPC German Collegiate Programming Contest (GCPC 2017) au ...

  8. Nordic Collegiate Programming Contest 2017 题解

    前几天打了一场外国人的比赛,感觉那边的题目质量还是很好的,区分度很鲜明,题目没有国内的难,坑点比较少,比较注重思维,基础算法. B题: Best Relay Team Picture by Ferna ...

  9. 2017-2018 ACM-ICPC German Collegiate Programming Contest (GCPC 2017)

    A Drawing Borders 很多构造方法,下图可能是最简单的了 代码: #include<bits/stdc++.h> using namespace std; const int ...

  10. Nordic Collegiate Programming Contest 2016

    A Artwork 输入: n,m表示原图为n*m个白色方格,输入x1,y1,x2,y2表示将x1,y1,x2,y2涂为黑色. 输出: 对于每个x1,y1,x2,y2输入当前图案白色联通块的数目. 思 ...

最新文章

  1. svn 建子项目的方法
  2. 基于边缘计算的实时绩效_基于绩效的营销中的三大错误
  3. vue弹层时禁止页面滚动
  4. [20190530]oracle Audit文件管理.txt
  5. python上传文件进度_python实现进度条--主要用在上传下载文件
  6. 【日本软件外包】设计书中常用到的文型
  7. Linq的内部执行原理浅析
  8. 亲测源码多多进鱼带VUE源码任务悬赏源码活动营销三级分销返佣积分商城版
  9. VS Code 取色器 插件 颜色选取
  10. 参加电子工业出版社博文视点举办的作者高峰论坛有感
  11. 用 Python 画哆啦 A 梦
  12. 【华为机试真题 Python实现】数大雁【2022 Q2 | 100分】
  13. 计算机绘图实训体会,CAD实习心得体会
  14. 动态壁纸:酷炫手机壁纸
  15. 马斯克“超级高铁”成功测速355km|h,不过仅比我国“复兴号”快5km|h
  16. TestDirector介绍
  17. cuda安装失败(cuda安装程序失败)
  18. linux 串口 中断方式,设置在linux下串口中断(setting serial port interruption in
  19. 高德地图鼠标经过点标记显示信息窗体
  20. 跟着NC学cfDNA全基因组片段化丰度谱分析

热门文章

  1. 批量将 txt 记事本文件按照固定行数拆分成单个独立的 txt 小文件
  2. 分享优秀品牌平面广告创意作品的创意密码
  3. 知识点滴 - 关于苹果认证MFI
  4. 【读过的书】《好看的皮囊千篇一律,有趣的灵魂万里挑一》
  5. html倒计时免费代码,JS倒计时代码汇总
  6. 使用hardhat 开发以太坊智能合约-发布合约
  7. JavaScript创建对象的方式
  8. 管理学必读书籍排行榜
  9. Weiss Ratings公布加密货币评级结果
  10. 交叉网线制作和用交叉网线tftp