An Animal Contest 2 P0 - Koala Matchmaking

View as PDF

Submit solution


Points: 3
Time limit: 0.5s
Memory limit: 256M

Authors:
Problem type

Contrary to common belief, Koalas are very socially active. Ken Koala has been on many matchmaking sites, and is now interested in making his own matchmaking algorithm. Ken's algorithm takes in a koala's favourite number, N, and chooses an optimal integer X < N such that the average of N and X, denoted by A, is an integer and is maximal. The Koala with favourite number N will be matched with a Koala with favourite number A.

Given the inputted value of N, you are to find the value of the integer, A.

Constraints

3 \le N \le 2 \cdot 10^9

Input Specification

The input will contain an integer N.

Output Specification

Output the value of the integer A.

Sample Input

15

Sample Output

14

Explanation for Sample

The optimal X to choose is 13, resulting in an average of \frac{15+13}{2} = 14.


Comments


  • 0
    someoneanony  commented on Oct. 18, 2024, 10:11 p.m.

    I don't understand, what is X?


    • 0
      someoneanony  commented on Oct. 18, 2024, 10:12 p.m.

      The 3 variables are X, N, and A. N is the input, A is the output. Whats X?


      • 1
        ev_code  commented on Oct. 19, 2024, 3:21 p.m.

        X is the value that you add to N. You have to find the maximum value for A. And A = (X + N) / 2. Where X < N.

        Hopefully this helps!