問題一覧 > 通常問題

No.3534 Make Many Fences

レベル : / AI推定難易度 : 1000 / 実行時間制限 : 1ケース 1.000秒 / メモリ制限 : 1024 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 84
作問者 : nauclhlt / テスター : gomaazarasi
お気に入りにしたユーザー ProblemId : 13159 / 自分の提出
問題文最終更新日: 2026-04-28 22:36:53
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 499 (順位表) の他の問題:

Problem Statement

You have $N$ pieces of wood and $M$ sticks, and you have no fences. You will now repeat the following, $0$ or more times: choose one of the $2$ actions below and perform it.

  • Action 1: Consume $2$ pieces of wood to create $4$ sticks. This action cannot be performed if you have fewer than $2$ pieces of wood.
  • Action 2: Consume $4$ pieces of wood and $2$ sticks to create $3$ fences. This action cannot be performed if you have fewer than $4$ pieces of wood or fewer than $2$ sticks.

Find the maximum possible number of fences you can have after finishing the sequence of actions.

Solve $T$ cases.

Input

$T$
$case_1$
$case_2$
$\vdots$
$case_T$
  • $1\leq T\leq 10^5$

$case_i$ represents the $i$-th test case and is given in the following format.

$N\ M$
  • $0\leq N\leq 10^9$
  • $0\leq M\leq 10^9$
  • All input values are integers.

Output

Print on one line the maximum possible number of fences you can have after finishing the actions.

End the output with a newline.

Sample

Sample 1
Input
3
64 0
24 5
0 100
Output
36
15
0

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。