CF690A1.Collective Mindsets (easy)

普及-

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Tonight is brain dinner night and all zombies will gather together to scarf down some delicious brains. The artful Heidi plans to crash the party, incognito, disguised as one of them. Her objective is to get away with at least one brain, so she can analyze the zombies' mindset back home and gain a strategic advantage.

They will be N guests tonight: N - 1 real zombies and a fake one, our Heidi. The living-dead love hierarchies as much as they love brains: each one has a unique rank in the range 1 to N - 1, and Heidi, who still appears slightly different from the others, is attributed the highest rank, N. Tonight there will be a chest with brains on display and every attendee sees how many there are. These will then be split among the attendees according to the following procedure:

The zombie of the highest rank makes a suggestion on who gets how many brains (every brain is an indivisible entity). A vote follows. If at least half of the attendees accept the offer, the brains are shared in the suggested way and the feast begins. But if majority is not reached, then the highest-ranked zombie is killed, and the next zombie in hierarchy has to make a suggestion. If he is killed too, then the third highest-ranked makes one, etc. (It's enough to have exactly half of the votes – in case of a tie, the vote of the highest-ranked alive zombie counts twice, and he will of course vote in favor of his own suggestion in order to stay alive.)

You should know that zombies are very greedy and sly, and they know this too – basically all zombie brains are alike. Consequently, a zombie will never accept an offer which is suboptimal for him. That is, if an offer is not strictly better than a potential later offer, he will vote against it. And make no mistake: while zombies may normally seem rather dull, tonight their intellects are perfect. Each zombie's priorities for tonight are, in descending order:

  1. survive the event (they experienced death already once and know it is no fun),
  2. get as many brains as possible.

Heidi goes first and must make an offer which at least half of the attendees will accept, and which allocates at least one brain for Heidi herself.

What is the smallest number of brains that have to be in the chest for this to be possible?

今晚是“大脑盛宴”之夜,所有僵尸将齐聚一堂,大快朵颐美味的大脑。机智的海蒂(Heidi)计划乔装成僵尸混入派对,暗中捣乱。她的目标是至少成功带走一颗大脑,以便回家后分析僵尸们的思维模式,从而获得战略优势。

今晚共有 NN 位宾客:其中 N−1N-1 位是真正的僵尸,还有一位是假扮的——也就是我们的海蒂。僵尸们酷爱等级制度,一如他们酷爱大脑:每位真实僵尸在 11 到 N−1N-1 范围内拥有唯一等级;而海蒂因外表仍略显异样,被赋予最高等级 NN。今晚现场将摆放一只装有若干大脑的宝箱,所有与会者都能清楚看到其中大脑总数。随后,这些大脑将按如下规则分配:

等级最高的僵尸首先提出一个分配方案(即每位与会者各得多少颗大脑;注意:每颗大脑不可分割)。接着进行投票。若至少半数与会者接受该方案,则大脑依此方案分配,盛宴随即开始。但若未获多数支持(即赞成票不足半数),则等级最高的僵尸将被处决,由剩余存活者中等级次高的僵尸提出新方案。若此人亦被处决,则由第三高等级者提出方案,依此类推。(注:此处“至少半数”指赞成票数 ≥N2\ge \frac{N}{2};若出现平票,则等级最高之存活者的票计为两票,且他必然投赞成票以保全自身性命。)

你应当知晓:僵尸极其贪婪且狡猾,且彼此心知肚明——归根结底,所有僵尸的头脑都如出一辙。因此,任何僵尸绝不会接受一个对他而言并非最优的方案。换言之,若某方案不严格优于他在后续阶段可能获得的结果,他必将投反对票。切勿误解:尽管僵尸平时看似迟钝,但今夜他们的智力臻于完美。每位僵尸今晚的优先级(由高到低)如下:

  1. 活过本次事件(他们已死过一次,深知死亡毫无乐趣);
  2. 尽可能多地获取大脑。

海蒂率先提案,她必须提出一个方案,满足两个条件:(1)至少获得半数与会者的赞成;(2)方案中分配给海蒂本人的大脑数量至少为 11。

问:宝箱中最少需要多少颗大脑,才能使上述目标成为可能?

输入格式

The only line of input contains one integer: N, the number of attendees (1 ≤ N ≤ 109).

输入仅包含一行,其中有一个整数:N,表示与会者人数(1 ≤ N ≤ 10⁹)。

输出格式

Output one integer: the smallest number of brains in the chest which allows Heidi to take one brain home.

输出一个整数:宝箱中脑的数量的最小值,使得海蒂能够带一个脑回家。

输入输出样例

  • 输入#1

    1

    输出#1

    1
  • 输入#2

    4

    输出#2

    2

输入解题思路,AI测评打分。不知道怎么写?

首页