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

3N2109

Input Specification

The input will contain an integer N.

Output Specification

Output the value of the integer A.

Sample Input

Copy
15

Sample Output

Copy
14

Explanation for Sample

The optimal X to choose is 13, resulting in an average of 15+132=14.


Comments


  • -1
    Mascara  commented 12 days ago edited

    I got an error trying to submit, it says it's incorrect, but it works, so is this just a DM::OJ thing or is my code wrong?

    Copy
    num = int(input())
    nums = int(input())
    
    def avg(num, nums):
        avg = (num+nums)//2
        return avg
    
    print(avg(num, nums))
    

    • 0
      AndyZhang68  commented 21 hours ago edited

      Please make sure to read the problem statement and input format carefully. The problem takes in only one integer as input, and so you should only read in one integer instead of two. The second integer is chosen to maximize the average of the two numbers, such that the average is an integer less than the first integer. Your program should output that average.


  • 0
    someoneanony  commented 78 days ago

    I don't understand, what is X?


    • 0
      someoneanony  commented 78 days ago

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


      • 1
        ev_code  commented 77 days ago

        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!