A. Sweet Problem

the first pile contains only red candies and there are r candies in it,

the second pile contains only green candies and there are g candies in it,

the third pile contains only blue candies and there are b 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.

Input

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

Each test case is given as a separate line of the input. It contains three integers r, g and b (1≤r,g,b≤108) — the number of red, green and blue candies, respectively.

Output

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

Example

input

6

1 1 1

1 2 1

4 1 1

7 4 10

8 1 4

8 2 8

output

1

2

2

10

5

9

Note

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.

题意

给你三个数,每次你可以选择其中两个数-1,然后问你最多减多少次,使得所有数都大于等于0

题解

视频题解 https://www.bilibili.com/video/av77514280/

其实答案就是min(a+b,(a+b+c)/2),考虑a+b和c的大小关系即可

代码

#include<bits/stdc++.h>
using namespace std; long long a[3];
void solve(){
for(int i=0;i<3;i++)
cin>>a[i];
sort(a,a+3);
cout<<min(a[0]+a[1],(a[0]+a[1]+a[2])/2)<<endl;
}
int main(){
int t;
cin>>t;
while(t--)solve();
}

Codeforces Round #603 (Div. 2) A. Sweet Problem 水题的更多相关文章

  1. Codeforces Round #603 (Div. 2) A. Sweet Problem(水.......没做出来)+C题

    Codeforces Round #603 (Div. 2) A. Sweet Problem A. Sweet Problem time limit per test 1 second memory ...

  2. Codeforces Round #603 (Div. 2) A. Sweet Problem(数学)

    链接: https://codeforces.com/contest/1263/problem/A 题意: You have three piles of candies: red, green an ...

  3. Codeforces Round #360 (Div. 2) C. NP-Hard Problem 水题

    C. NP-Hard Problem 题目连接: http://www.codeforces.com/contest/688/problem/C Description Recently, Pari ...

  4. Codeforces Round #603 (Div. 2) B. PIN Codes 水题

    B. PIN Codes A PIN code is a string that consists of exactly 4 digits. Examples of possible PIN code ...

  5. Codeforces Round #367 (Div. 2) A. Beru-taxi (水题)

    Beru-taxi 题目链接: http://codeforces.com/contest/706/problem/A Description Vasiliy lives at point (a, b ...

  6. Codeforces Round #334 (Div. 2) A. Uncowed Forces 水题

    A. Uncowed Forces Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/604/pro ...

  7. Codeforces Round #353 (Div. 2) A. Infinite Sequence 水题

    A. Infinite Sequence 题目连接: http://www.codeforces.com/contest/675/problem/A Description Vasya likes e ...

  8. Codeforces Round #343 (Div. 2)【A,B水题】

    A. Far Relative's Birthday Cake 题意: 求在同一行.同一列的巧克力对数. 分析: 水题~样例搞明白再下笔! 代码: #include<iostream> u ...

  9. Codeforces Round #327 (Div. 2) A. Wizards' Duel 水题

    A. Wizards' Duel Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/591/prob ...

随机推荐

  1. NuGet修改默认包保存的位置

    NuGet默认的全局包下载地址一般为:C:\Users\{username}\.nuget\packages 修改方法: <?xml version="1.0" encodi ...

  2. [20191127]表 full Hash Value的计算.txt

    [20191127]表 full Hash Value的计算.txt --//曾经做过表full Hash Value的计算,当时我是通过建立简单的schema以及表名的形式,使用hashcat破解o ...

  3. 范罗士空气净化器PT65评测

    买了一台空气净化器,之前网上查了查,哟,是个知名品牌,做碎纸机的. 你问我为啥找个卖碎纸机的买空气净化器?因为年轻,咱们往下看 包装还可以 一打开就有疑问了,这塑料味道不对呀,三手料也不该这个味儿啊. ...

  4. NIO零拷贝的深入分析

    深入分析通过Socket进行数据文件传递中的传统IO的弊端以及NIO的零拷贝实现原理,及用户空间和内核空间的切换方式 传统的IO流程 在这个过程中: 数据从磁盘拷贝进内核空间缓冲区 从内核空间缓冲区拷 ...

  5. Kubernetes的CronJob对象

    CronJob说白了就是用来管理Job对象的控制器, 通过jobTemplate管理Job对象,定时执行,最终实现我们的cron功能 示例 apiVersion: batch/v1beta1 kind ...

  6. Selenium模块的安装

    Selenium模块 1.安装selenium python2:pip install selenium python3:pip install selenium 2.设置浏览器驱动 解压后必须与浏览 ...

  7. Hacking/Penetrating tester bookmark collection

    Blogs http://carnal0wnage.blogspot.com/ http://www.mcgrewsecurity.com/ http://www.gnucitizen.org/blo ...

  8. JS 逻辑

    JS 逻辑 Boolean(逻辑)对象用于将非逻辑值转换为逻辑值(true 或者 false). Boolean 对象 您可以将 Boolean 对象理解为一个产生逻辑值的对象包装器. Boolean ...

  9. DOM HTML

    DOM HTML HTML DOM 允许 JavaScript 改变 HTML 元素的内容. 改变 HTML 输出流 JavaScript 能够创建动态的 HTML 内容: 今天的日期是: Tue J ...

  10. 基于 Storyboard 多种方式的页面跳转、参数传递

    原文 通过按钮关联跳转 选中 Button ,然后点击 action 右边拖拽到 第二个页面 选择 "Show"即可完成跳转关联. 定义页面间 segue Id,通过代码触发跳转 ...