問題一覧 > 通常問題

No.2297 Best Grouping

レベル : / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 268
作問者 : Shirotsume / テスター : 👑 p-adic ygussany
お気に入りにしたユーザー ProblemId : 9285 / 自分の提出
問題文最終更新日: 2023-04-26 21:58:35
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 388 (順位表) の他の問題:

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もしくは右上の雲マークをクリックしてアカウントを作成してください。