codeforces-scrape

Codeforces scraped problems and editorials
git clone git://git.laack.co/codeforces-scrape.git
Log | Files | Refs | README

690A1.md (2819B)


      1 Source: https://codeforces.com/problemset/problem/690/A1
      2 
      3 A1. Collective Mindsets (easy)
      4 
      5 time limit per test
      6 
      7 1 second
      8 
      9 memory limit per test
     10 
     11 256 megabytes
     12 
     13 input
     14 
     15 standard input
     16 
     17 output
     18 
     19 standard output
     20 
     21 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.
     22 
     23 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:
     24 
     25 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.)
     26 
     27 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:
     28 
     29 1. survive the event (they experienced death already once and know it is no fun),
     30 2. get as many brains as possible.
     31 
     32 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.
     33 
     34 What is the smallest number of brains that have to be in the chest for this to be possible?
     35 
     36 Input
     37 
     38 The only line of input contains one integer: *N*, the number of attendees (1 ≤ *N* ≤ 109).
     39 
     40 Output
     41 
     42 Output one integer: the smallest number of brains in the chest which allows Heidi to take one brain home.
     43 
     44 Examples
     45 
     46 Input
     47 
     48 ```
     49 1
     50 ```
     51 
     52 Output
     53 
     54 ```
     55 1
     56 ```
     57 
     58 Input
     59 
     60 ```
     61 4
     62 ```
     63 
     64 Output
     65 
     66 ```
     67 2
     68 ```
     69 
     70 Note