CF725D Contest Balloons
题目描述
ACM比赛,大家都知道。AC一题会有一个气球。
现在有$n(2
输入格式
第一行:一个正整数$n(2
输出格式
仅有一行,输出你带领的队伍能够达到的最好名次
感谢@2016wudi 提供的翻译
说明/提示
In the first sample, Limak has $ 20 $ balloons initially. There are three teams with more balloons ( $ 32 $ , $ 40 $ and $ 45 $ balloons), so Limak has the fourth place initially. One optimal strategy is:
1. Limak gives $ 6 $ balloons away to a team with $ 32 $ balloons and weight $ 37 $ , which is just enough to make them fly. Unfortunately, Limak has only $ 14 $ balloons now and he would get the fifth place.
2. Limak gives $ 6 $ balloons away to a team with $ 45 $ balloons. Now they have $ 51 $ balloons and weight $ 50 $ so they fly and get disqualified.
3. Limak gives $ 1 $ balloon to each of two teams with $ 16 $ balloons initially.
4. Limak has $ 20-6-6-1-1=6 $ balloons.
5. There are three other teams left and their numbers of balloons are $ 40 $ , $ 14 $ and $ 2 $ .
6. Limak gets the third place because there are two teams with more balloons.
In the second sample, Limak has the second place and he can't improve it.
In the third sample, Limak has just enough balloons to get rid of teams $ 2 $ , $ 3 $ and $ 5 $ (the teams with $ 81000000000 $ , $ 5000000000 $ and $ 46000000000 $ balloons respectively). With zero balloons left, he will get the second place (ex-aequo with team $ 6 $ and team $ 7 $ ).