• 一道二分题


    题目:

      

    Problem Description

    Gashuai is a brave man live in a grand castle peacefully.However, there are many monsters want to invade the castle one day. Gashuai, the hero of the castle, want to defend the castle against monsters. The monsters comes one by one and each monster cost Gashuai a[i] HP to kill it. Gashuai has n maximum HP at first . After each fight , Gashuai can choose to reduce maximum HP by 10% and recover his current HP to maximum. To simplify this problem ,the calculation will in integer not decimal. For example , if Gashuai has 99 maximum HP , his maximum HP will reduce 99*0.1=9, and becomes 90.Of coursr, if Gashuai’s maximum HP is lower than 10, he won’t reduce maximum HP as 9*0.1=0. Gashuai’s HP shouldn’t be less than 1 after each fight. Please calculate how much HP(maximum HP) should Gashuai have before his first fight at least .Of course his current HP is same as his maximum HP before his first fight.

    Input

    The input contains several test cases ( no more than 20 ) , terminated by EOF.
    The first line of each test contains one integers n ( 1 ≤ n ≤ 500000), indicating the number of monsters.
    The second line contains n numbers and the ith number means the ith monster costs Gashuai a[i] current HP to kill it( 0 ≤ a[i] ≤ 1000).
    Notice that the monsters come in order.

    Output

    For each test case print 1 integers in a line,indicating the initial HP Gashuai most have before the first fight.

    Sample Input

    3
    3 2 1
    8
    7 4 3 8 6 5 2 7
    13
    1 12 5 7 11 13 7 8 9 10 10 5 13

    Sample Output

    4
    9
    25

    Author

    bytelin

    Source

    第八届浙江科技学院ACM程序设计竞赛
    题目答案很简单,二分答案就可以,但是比赛的时候WA12次,我试了很多遍,赛后也问了很多大牛,都说直接二分就好,
    原因就是我题意理解的太。。。。。。。。。

            Gashuai can choose to reduce maximum HP by 10% and recover his current HP to maximum

                          我理解成每次减少当前MAX_HP的10%,如果现在的HP小于这MAX_HP的10%,就OUT这种答案,

                   这就是我英语渣的原因吗?

                                 正解是:

                                             变化的是MAX_HP,MAX_HP每次不够时,自减10%,然后二分

                            。。。。。。。

    无力吐槽了

    实在是渣!!!

                                        

    随性Code
  • 相关阅读:
    读书笔记:7个示例科普CPU Cache
    no such partition grub rescue>
    这些个云盘
    原版win7镜像IE主页被篡改?
    JS判断访问设备、客户端操作系统类型
    floodlight make the VMs can not getDHCP IP address
    MPI之聚合通信-Scatter,Gather,Allgather
    MPI 环境搭建问题-运行程序闪退
    【算法、递归回溯解决数独】
    算法【最大子序列问题】
  • 原文地址:https://www.cnblogs.com/forgot93/p/3489398.html
Copyright © 2020-2023  润新知