No.2297 Best Grouping
タグ : / 解いたユーザー数 268
作問者 :
Problem Statement
$N$ participants have gathered for an onsite contest. In this contest, participants compete in groups of $2$ or $3$ people. The participants will now be divided into groups so that each person belongs to exactly $1$ group.
However, since a group of $2$ people has fewer members than a group of $3$ people and is at a disadvantage, the grouping is done so that there are as few $2$-person groups as possible.
Find the minimum possible number of $2$-person groups when the $N$ people are divided into groups. Under the constraints of this problem, a grouping is always possible.
Constraints
- $N$ is an integer
- $2 \leq N \leq 10^9$
Input
The input is given from Standard Input in the following format.
$N$
Output
Output the answer.
Sample
Sample 1
Input
7
Output
2
You can divide the $7$ people into groups of $3$, $2$, and $2$ people. The number of $2$-person groups cannot be made less than $2$.
Sample 2
Input
5
Output
1
It is best to divide the $5$ people into groups of $3$ and $2$ people.
Sample 3
Input
3
Output
0
$3$ people have come to the onsite. These $3$ people form $1$ group as they are, and the contest is held.
Sample 4
Input
998244353
Output
1
$998244353$ people have come to the onsite. The future of competitive programming is secure.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。