Hihocoder #1095 : HIHO Drinking Game (微软笔试题)
来源:互联网 发布:神仙劫翅膀进阶数据 编辑:程序博客网 时间:2024/04/27 21:02
题目1 : HIHO Drinking Game
- 样例输入
5 63 6 6 2 1
- 样例输出
4
描述
Little Hi and Little Ho are playing a drinking game called HIHO. The game comprises N rounds. Each round, Little Hi pours T milliliter of water into Little Ho's cup then Little Ho rolls a K-faces dice to get a random number d among 1 to K. If the remaining water in Little Ho's cup is less than or equal to d milliliter Little Hi gets one score and Little Ho drinks up the remaining water, otherwise Little Ho gets one score and Little Ho drinks exactly d milliliter of water from his cup. After N rounds who has the most scores wins.
Here comes the problem. If Little Ho can predict the number d of N rounds in the game what is the minimum value of T that makes Little Ho the winner? You may assume that no matter how much water is added, Little Ho's cup would never be full.
输入
The first line contains N(1 <= N <= 100000, N is odd) and K(1 <= K <= 100000).
The second line contains N numbers, Little Ho's predicted number d of N rounds.
输出
Output the minimum value of T that makes Little Ho the winner.
题意分析
小Hi和小Ho正在玩这样一个游戏,在每局游戏的开始,小Hi手持一瓶可以认为是无穷无尽的饮料,而小Ho手中有一个空杯子。
一局游戏分为N轮,在每轮行动中,小Hi先向小Ho手中的杯子倒入T个单位的饮料(倒入的数量在一局游戏开始之前约定好且在整局游戏中固定),然后小Ho掷出一个均匀的K面骰子得到一个1..K之间的数d,如果杯中饮料的单位数小于等于d,则小Hi记一分,且小Ho将杯中剩余饮料一饮而尽,否则小Ho记一分,小Ho喝掉杯中d个单位的饮料。在N轮结束后,分高者获胜。
那么问题来了,如果小Ho能够预测这局中每轮自己所掷出的点数,那么最小的能使得小Ho获胜的T(每轮小Hi倒入小Ho杯子的饮料的单位数)是多少?
杯子的饮料的单位数和你选着的T有关。
应为T越大Ho的分数就越大,所以可以用二分
中间题意没看懂,一直是WA。
- Hihocoder #1095 : HIHO Drinking Game (微软笔试题)
- hihoCoder 1095 HIHO Drinking Game 微软苏州校招笔试 12月27日
- HIHO Drinking Game
- HIHO Drinking Game
- 微软hiho上的笔试题:Tower Defense Game
- hiho练习“Drinking Game"二分搜索
- 【hihocoder】Font Size(微软2016.4校招笔试题)
- hiho一下 第六十九周 题目1 : HIHO Drinking Game 二分
- 微软笔试题 HihoCoder#1137: Recruitment 题解
- 【hihoCoder】#1086: Browser Caching (微软笔试题)
- hiho一下 微软笔试题《String Matching Content Length》
- 【hihocoder】hiho密码(水题)
- hihocoder 1534 微软探星夏令营笔试A题 (STL)
- 微软笔试题 HihoCoder#1136: Professor Q's Software 题解
- hihocoder 1289 2017年微软实习笔试题
- hihoCoder #1490 : Tree Restoration 微软2017在线笔试题
- hihoCoder(1)——hiho密码
- 【HihoCoder】1283 - hiho密码(水)
- IOS之同步请求、异步请求、GET请求、POST请求
- Windows7和Ubuntu15.04互相远程控制(在相同内网)
- Role保存Menu
- android部分目录分析
- oracle课堂收录-函数举例
- Hihocoder #1095 : HIHO Drinking Game (微软笔试题)
- ZwCreateFile打开文件时出现SHARE_VIOLATION的问题的一种情况
- Android JNI实现计算器demo
- iOS富文本(一)属性化字符串
- iOS target
- 音频编码之opus(一)
- java 快速排序
- UNIX Tutorial for Beginners
- 杨氏矩阵及其变形