AT_arc222_b.Circular RPS

提高+/省选-

通过率:0%

时间限制:2.00s

内存限制:1024MB

AC君温馨提醒

该题目为【atcoder】题库的题目,您提交的代码将被提交至atcoder进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

A rock-paper-scissors tournament was held with a+b+ca+b+c participants. Here, a,b,ca, b, c are non-negative integers with 3≤a+b+c3\leq a+b+c.

In the tournament, all participants first stand in a circle. Then, each participant plays "Rock," "Scissors," or "Paper."

For each participant, if the hand they played beats both the hand of the participant to their left and the hand of the participant to their right, that participant becomes a winner. There is not necessarily exactly one winner; there may be zero, or two or more winners.

More formally, a participant becomes a winner if one of the following holds:

  • The participant played "Rock," and both the left neighbor and the right neighbor played "Scissors."
  • The participant played "Scissors," and both the left neighbor and the right neighbor played "Paper."
  • The participant played "Paper," and both the left neighbor and the right neighbor played "Rock."

The following is known about this tournament:

  • aa participants played "Rock."
  • bb participants played "Scissors."
  • cc participants played "Paper."

Under this condition, find the maximum possible number of winners in the tournament.

TT test cases are given; solve each of them.

一场剪刀-石头-布锦标赛共有 a+b+ca+b+c 名参赛者。其中,a,b,ca, b, c 是非负整数,且满足 3≤a+b+c3\leq a+b+c。

在该锦标赛中,所有参赛者首先围成一个圆圈站立,然后每人各出“石头”、“剪刀”或“布”中的一种手势。

对每名参赛者而言,若其所出手势同时击败其左侧邻居和右侧邻居的手势,则该参赛者成为获胜者。获胜者人数不一定是恰好一人;可能为零人,也可能为两人或更多人。

更严格地定义如下:当且仅当满足以下任一条件时,一名参赛者成为获胜者:

  • 该参赛者出“石头”,且其左侧邻居与右侧邻居均出“剪刀”;
  • 该参赛者出“剪刀”,且其左侧邻居与右侧邻居均出“布”;
  • 该参赛者出“布”,且其左侧邻居与右侧邻居均出“石头”。

已知本次锦标赛中:

  • 有 aa 名参赛者出“石头”;
  • 有 bb 名参赛者出“剪刀”;
  • 有 cc 名参赛者出“布”。

在此条件下,求锦标赛中获胜者人数的最大可能值。

共给出 TT 组测试用例,请分别求解。

输入格式

The input is given from Standard Input in the following format:

TT
case1\mathrm{case}_1
case2\mathrm{case}_2
⋮\vdots
caseT\mathrm{case}_T

Each test case is given in the following format:

aa bb cc

输入从标准输入中按以下格式给出:

TT
case1\mathrm{case}_1
case2\mathrm{case}_2
⋮\vdots
caseT\mathrm{case}_T

每个测试用例按以下格式给出:

aa bb cc

输出格式

Output one line per test case.

For each test case, output the maximum possible number of winners in the tournament.

每个测试用例输出一行。

对于每个测试用例,输出锦标赛中可能的最大获胜者数量。

输入输出样例

  • 输入#1

    6
    3 1 2
    2 2 2
    123 456 789
    10 0 0
    10 0 100
    100 0 10

    输出#1

    2
    1
    578
    0
    9
    10

说明/提示

Sample 1 Explanation:
Let us explain the first test case. Consider the case where the hands played by the six participants are represented as in the following figure. In the figure, a participant who played "Rock" is denoted by A, a participant who played "Scissors" is denoted by B, and a participant who played "Paper" is denoted by C.

In this figure, there are three participants who played "Rock," one participant who played "Scissors," and two participants who played "Paper," which matches the input. In this case, the winners of the tournament are the two participants who played "Paper."

Constraints

  • 1≤T≤5×1051\leq T\leq 5\times 10^5
  • 0≤a,b,c≤1090\leq a, b, c\leq 10^9
  • 3≤a+b+c3\leq a+b+c
  • All input values are integers.

样例 1 解释:
我们来解释第一个测试用例。考虑如下图所示的六名参与者各自出的手势。图中,出“石头”的参与者用 A 表示,出“剪刀”的参与者用 B 表示,出“布”的参与者用 C 表示。

在该图中,有三名参与者出“石头”,一名参与者出“剪刀”,两名参与者出“布”,这与输入一致。在此情况下,锦标赛的获胜者是两名出“布”的参与者。

约束条件

  • 1≤T≤5×1051\leq T\leq 5\times 10^5
  • 0≤a,b,c≤1090\leq a, b, c\leq 10^9
  • 3≤a+b+c3\leq a+b+c
  • 所有输入值均为整数。

输入解题思路,AI测评打分。不知道怎么写?

首页