Skip to content

Latest commit

 

History

History

waiting-room

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

There's a waiting room with N chairs set in single row. Chairs are consecutively numbered from 1 to N. First is closest to the entrance (which is exit as well).

For some reason people choose a chair in the following way

  1. Find a place as far from other people as possible
  2. Find a place as close to exit as possible

All chairs must be occupied before the first person will be served

So it looks like this for 10 chairs and 10 patients

Chairs 1 2 3 4 5 6 7 8 9 10
Patients 1 7 5 8 3 9 4 6 10 2

Your task is to find last patient's chair's number.

Input - N - integer greater than 2 - number of chairs. Output should positive integer too - last patient's chair's number