题目:甜蜜的问题##

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

第一堆有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. Servlet——用户登录案例

    案例:用户登录 * 用户登录案例需求: 1.编写login.html登录页面 username & password 两个输入框 2.使用Druid数据库连接池技术,操作mysql,day14 ...

  2. Hadoop压缩的图文教程

    近期由于Hadoop集群机器硬盘资源紧张,有需求让把 Hadoop 集群上的历史数据进行下压缩,开始从网上查找的都是关于各种压缩机制的对比,很少有关于怎么压缩的教程(我没找到..),再此特记录下本次压 ...

  3. JavaWeb核心知识点

    一:HTTP协议     一.概述 1. 概念:超文本传输协议 2. 作用:规范了客户端(浏览器)和服务器的数据交互格式 3. 特点 1. 简单快速:客户端向服务器请求服务时,仅通过键值对来传输请求方 ...

  4. openresty(nginx)中使用lua脚本获取请求IP地址的代码

    人狠话不多,直接上代码:------------------------------------------------------------------------------------- lo ...

  5. class继承关键字extends和super

    // 父类 class person { constructor (name,age) { this.name = name this.age = age } } class CheChinese e ...

  6. 访问formData的数据

    vant-ui 的 Uploader 上传图片时,用到formData let fd = new FormData(); fd.append('upImgs', file.file); postIma ...

  7. vue监听移动设备的返回事件

    在公共方法文件common.js中实现一个存储当前历史记录的方法 common.js // 存储当前历史记录点,实现控制手机物理返回键的按钮事件 var pushHistory = function ...

  8. JavaWeb01-常识

    软件系统体系结构 1        常见软件系统体系结构B/S.C/S 1.1 C/S l  C/S结构即客户端/服务器(Client/Server),例如QQ: l  需要编写服务器端程序,以及客户 ...

  9. mysql--时区表问题(Windows环境下)

    自己用Django开发个人博客是,数据库用的是mysql,期间遇到一个时间不一致的问题,具体解决过程: 1.问题原因:Windows没有时区表 2.去mysql官网下载相应版本的时区表:https:/ ...

  10. 驰骋工作流系统-Java共工作流引擎配置定时任务

    关键词:工作流定时任务  流程引擎定时任务设置  工作流系统定时任务配置  开源工作流引擎 开源工作流系统 一.定时任务的作用 发送邮件,发送短信. 处理节点自动执行的任务.比如:一个节点的待办工作是 ...