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. git上传本地项目到github或者gitlib(两个是一样的)。

    第一步:在github上面创建一个repository   点击create就好了.然后会出现下面的页面. 第三步:打开你所在文件夹,或者是新建的文件夹(用来做仓库的)右键会出现下面  选用git B ...

  2. Python学习笔记六(免费获取代理IP)

    为获取网上免费代理IP,闲的无聊,整合了一下,免费从三个代理网站获取免费代理IP,目的是在某一代理网站被限制时,仍可从可以访问的其他网站上获取代理IP.亲测可用哦!^_^  仅供大家参考,以下脚本可添 ...

  3. 编辑器之神vim的一些常用快捷键整理

    yy:复制 光标所在的这一行 4yy:复制 光标所在行开始向下的4行 p:粘贴 dd:剪切(删除) 光标所在的这一行 4dd:剪切(删除) 光标所在行向下的4行 D:从当前的光标开始向后剪切,一直到行 ...

  4. MAC地址表(交换机)、ARP缓存表以及路由表(路由器)

  5. Java 正则表达式_网络爬虫

    首先 需要了解 一些 关于 网络爬虫的 基本知识: 网络爬虫: 所谓的 爬虫 就是一个 应用 程序, 这个 应用 程序 会 获取 网络中的 指定信息(网页 数据). 例如百度: 启动 这个 爬虫 程序 ...

  6. 一文带你深入浅出Spring 事务原理

    Spring事务的基本原理 Spring事务的本质其实就是数据库对事务的支持,没有数据库的事务支持,spring是无法提供事务功能的.对于纯JDBC操作数据库,想要用到事务,可以按照以下步骤进行: 获 ...

  7. JAVA集合框架(二)-List和Set

    List的常用实现类 list集合是有序的,顺序即添加的顺序,元素是可重复的. ArrayList LinkedList Vector ArrayList 底层基于数组实现.在add元素的过程中,如果 ...

  8. Selenium(四):CSS选择器(一)

    1. CSS选择器 前面我们学习了根据 id.class属性.tag名选择元素. 如果我们要选择的元素没有id.class 属性,或者有些我们不想选择的元素也有相同的id.class属性值,怎么办呢? ...

  9. 使用session存储,购物车结算add_to_order.php(学生笔记)

    <?php session_start(); include_once("DB.class.php"); //接受并解析前端传过来的json,转换成数组. $goods_li ...

  10. CRM第二篇

    检索策略 : 相当于优化查询,主要是分为立即加载和延迟加载. 当你查询一个对象的时候,要想立马使用这个对象,或者说是立即查询出来,就使用立即加载. 当你查询这个对象时候不想立马查询出来,而是在使用这个 ...