LCC '24 Contest 2 J3 - Eric's Apple Orchard

View as PDF

Submit solution


Points: 5 (partial)
Time limit: 2.0s
Memory limit: 256M

Author:
Problem type

Eric owns an apple orchard. Every year, he can sell them to Ning, who owns the local supermarket. However, for every apple Eric sells, Ning pays $1 less per apple. Specifically, Eric can sell X apples for N-X dollars per apple.

Please help Eric find the smallest integer value of X that maximizes his revenue.

Input Specification

The first and only line of input will contain a positive integer N, representing the starting value that Ning buys apples for.

Output Specification

The only line of output will output the smallest value of X that maximizes Eric's revenue.

Subtasks

1 \leq N \leq 10^{18}

Subtask 1 [25%]

1 \leq N \leq 10^6

Subtask 2 [75%]

No additional constraints.

Sample Input 1

6

Sample Output 1

3

Explanation for Sample Output 1

Notice that if X < 0 or X > 6, then Eric's revenue is negative! He should be able to make more money by not selling apples.

Additionally, if X = 0 or X = 6, then his revenue is exactly zero.

If X = 1, then Eric's revenue is $5.

If X = 2, then Eric's revenue is $8.

If X = 3, then Eric's revenue is $9.

If X = 4, then Eric's revenue is $8.

If X = 5, then Eric's revenue is $5.

Therefore, Eric's profit is maximized when he sells 3 apples to Ning.

Sample Input 2

15

Sample Output 2

7

Comments

There are no comments at the moment.