CF1263A.Sweet Problem

普及-

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

You have three piles of candies: red, green and blue candies:

  • the first pile contains only red candies and there are rr candies in it,
  • the second pile contains only green candies and there are gg candies in it,
  • the third pile contains only blue candies and there are bb candies in it.

Each day Tanya eats exactly two candies of different colors. She is free to choose the colors of eaten candies: the only restriction that she can't eat two candies of the same color in a day.

Find the maximal number of days Tanya can eat candies? Each day she needs to eat exactly two candies.

你有三堆糖果:红色、绿色和蓝色糖果:

  • 第一堆只包含红色糖果,共有 rr 颗;
  • 第二堆只包含绿色糖果,共有 gg 颗;
  • 第三堆只包含蓝色糖果,共有 bb 颗。

塔尼娅每天恰好吃两颗颜色不同的糖果。她可以自由选择所吃糖果的颜色,唯一限制是:她每天不能吃两颗相同颜色的糖果。

求塔尼娅最多能吃多少天?每天她必须恰好吃两颗糖果。

输入格式

The first line contains integer tt (1≤t≤10001 \le t \le 1000) — the number of test cases in the input. Then tt test cases follow.

Each test case is given as a separate line of the input. It contains three integers rr, gg and bb (1≤r,g,b≤1081 \le r, g, b \le 10^8) — the number of red, green and blue candies, respectively.

第一行包含一个整数 tt(1≤t≤10001 \le t \le 1000)—— 输入中测试用例的数量。随后是 tt 个测试用例。

每个测试用例在输入中占单独一行,包含三个整数 rr、gg 和 bb(1≤r,g,b≤1081 \le r, g, b \le 10^8),分别表示红色、绿色和蓝色糖果的数量。

输出格式

Print tt integers: the ii-th printed integer is the answer on the ii-th test case in the input.

输出 tt 个整数:第 ii 个输出的整数为输入中第 ii 个测试用例的答案。

输入输出样例

  • 输入#1

    6
    1 1 1
    1 2 1
    4 1 1
    7 4 10
    8 1 4
    8 2 8

    输出#1

    1
    2
    2
    10
    5
    9

说明/提示

In the first example, Tanya can eat candies for one day only. She can eat any pair of candies this day because all of them have different colors.

In the second example, Tanya can eat candies for two days. For example, she can eat red and green candies on the first day, and green and blue candies on the second day.

In the third example, Tanya can eat candies for two days. For example, she can eat red and green candies on the first day, and red and blue candies on the second day. Note, that two red candies will remain uneaten.

在第一个例子中,塔尼娅只能吃一天糖果。她当天可以吃任意一对糖果,因为所有糖果的颜色都不同。

在第二个例子中,塔尼娅可以吃两天糖果。例如,她第一天可以吃红色和绿色糖果,第二天可以吃绿色和蓝色糖果。

在第三个例子中,塔尼娅可以吃两天糖果。例如,她第一天可以吃红色和绿色糖果,第二天可以吃红色和蓝色糖果。注意,将剩下两颗红色糖果未被吃掉。

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

首页