题目:甜蜜的问题##

题意:你有三堆糖果:红色,绿色,蓝色

第一堆有r个糖果,第二堆有g个糖果,第三堆有b个糖果

每天都可以吃两个不同颜色的糖果,找出可以吃糖果的最大天数

分析:先排下序,如果最大堆大于等于其它两堆的和,那么答案是另外两堆的和,如果小于其它两堆的和,那么首先可以先消掉最大堆,另外两堆要分摊消掉的糖果,

其次还要将剩余的两堆互相消掉,因为要尽量得到最大天数,因此要将两堆分摊成相同的两堆。

#include <cstdio>
#include <iostream>
#include <algorithm> using namespace std;
int a[3];
int t;
int main()
{
cin >> t;
while (t--)
{
cin >> a[0] >> a[1] >> a[2]; sort(a, a + 3); if (a[2] >= a[0] + a[1])
printf("%d\n", a[0] + a[1]);
else
{
//a[2] < a[0] + a[1] int res = 0;
res += a[2]; int t = (a[0] + a[1] - a[2]) / 2;
res += t;
printf("%d\n", res);
} } return 0;
}

A.Sweet Problem的更多相关文章

  1. Codeforces Round #603 (Div. 2) A. Sweet Problem 水题

    A. Sweet Problem the first pile contains only red candies and there are r candies in it, the second ...

  2. 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 ...

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

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

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

    #include <cstdio> #include <algorithm> using namespace std; int main() { int t; scanf(&q ...

  5. [CodeForces]1263A Sweet Problem

    题目链接 题目描述 You have three piles of candies: red, green and blue candies: the first pile contains only ...

  6. CF#603 Div2

    差不多半年没打cf,还是一样的菜:不过也没什么,当时是激情,现在已是兴趣了,开心就好. A Sweet Problem 思维,公式推一下过了 B PIN Codes 队友字符串取余过了,结果今天早上一 ...

  7. Codeforces Round #603 (Div. 2)

    传送门 感觉脑子还是转得太慢了QAQ,一些问题老是想得很慢... A. Sweet Problem 签到. Code /* * Author: heyuhhh * Created Time: 2019 ...

  8. Codeforces Round #603 (Div. 2) (题解)

    A. Sweet Problem (找规律) 题目链接 大致思路: 有一点瞎猜的,首先排一个序, \(a_1>a_2>a_3\) ,发现如果 \(a_1>=a_2+a_3\) ,那么 ...

  9. [Codeforces] #603 (Div. 2) A-E题解

    [Codeforces]1263A Sweet Problem [Codeforces]1263B PIN Code [Codeforces]1263C Everyone is a Winner! [ ...

随机推荐

  1. 平滑启动shell脚本

    # 平滑关闭和启动 Spring Boot 程序#设置端口SERVER_PORT="8090"#当前时间time=`date +%Y-%m-%d`#设置应用名称JAR_NAME=& ...

  2. 用PHP+Redis实现延迟任务,实现自动取消订单

    简单定时任务解决方案:使用redis的keyspace notifications(键失效后通知事件) 需要注意此功能是在redis 2.8版本以后推出的,因此你服务器上的reids最少要是2.8版本 ...

  3. Python 常用模块系列学习(3)--configparser module

    configpaser 模块----用于生成和修改常见配置文档 1. config 对象的创建: import configparser #导入模块 config = configparser.Con ...

  4. 通过C/C++,实现一元一次方程求解

    通过C/C++,实现一元一次方程求解: #include <bits/stdc++.h> using namespace std; string str, str_l, str_r; st ...

  5. java操作RabbitMQ添加队列、消费队列和三个交换机

    假设已经在服务器上安装完RabbitMQ.我写的教程 一.发送消息到队列(生产者) 新建一个maven项目,在pom.xml文件加入以下依赖 <dependencies> <depe ...

  6. 管理系统和服务systemctl(centos6:chkconfig、service命令)

    传统:SysV init 红帽6.Ubuntu6:采用Upstart 红帽7:采用全新的Systemd SysV init运行级别,主题思想是串行的启动所有将来需要用到的服务(所以计算机没有利用多CP ...

  7. ftp用户和密码

    centos7 FTP修改密码: 1.查看ftp的用户:cat /etc/vsftpd/ftpusers 2.passwd ftp的用户 (输入两次) 3.重启ftp:service vsftpd r ...

  8. 三种方法教你HTML实现点击某一个元素之外触发事件

    HTML实现点击某一个元素之外触发事件 大致编写的HTML界面渲染后是这个样子的,我们现在想要实现的需求是点击Button所在的div不会触发事件,而在点击Button所在的div之外的区域时会触发事 ...

  9. Dart Learn Notes 02

    Functions Dart是一门面向对象的语言,所以即便是方法也是一个对象,它的类型是Function. 这就意味着方法可以指向变量,也可以作为方法中的参数供其他方法使用.甚至可以让 一个类作为一个 ...

  10. Maven搭建SpringMvc

    Maven搭建SpringMvc,只需跟着一步步操作 项目结构 1 创建Maven项目 index,jsp报错不用管,配置完pom就好了,也可以直接删除掉 2 pom.xml添加依赖 <depe ...