A.Sweet Problem
题目:甜蜜的问题##
题意:你有三堆糖果:红色,绿色,蓝色
第一堆有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的更多相关文章
- 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 ...
- 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 ...
- Codeforces Round #603 (Div. 2) A. Sweet Problem(数学)
链接: https://codeforces.com/contest/1263/problem/A 题意: You have three piles of candies: red, green an ...
- Codeforces Round #603 (Div. 2) A.Sweet Problem
#include <cstdio> #include <algorithm> using namespace std; int main() { int t; scanf(&q ...
- [CodeForces]1263A Sweet Problem
题目链接 题目描述 You have three piles of candies: red, green and blue candies: the first pile contains only ...
- CF#603 Div2
差不多半年没打cf,还是一样的菜:不过也没什么,当时是激情,现在已是兴趣了,开心就好. A Sweet Problem 思维,公式推一下过了 B PIN Codes 队友字符串取余过了,结果今天早上一 ...
- Codeforces Round #603 (Div. 2)
传送门 感觉脑子还是转得太慢了QAQ,一些问题老是想得很慢... A. Sweet Problem 签到. Code /* * Author: heyuhhh * Created Time: 2019 ...
- Codeforces Round #603 (Div. 2) (题解)
A. Sweet Problem (找规律) 题目链接 大致思路: 有一点瞎猜的,首先排一个序, \(a_1>a_2>a_3\) ,发现如果 \(a_1>=a_2+a_3\) ,那么 ...
- [Codeforces] #603 (Div. 2) A-E题解
[Codeforces]1263A Sweet Problem [Codeforces]1263B PIN Code [Codeforces]1263C Everyone is a Winner! [ ...
随机推荐
- Comet OJ - 2019国庆欢乐赛 C题 两排房子
###题目链接### 题目大意:这里有横着的两排房子,给你每个房子的左端点和右端点.若两排房子中分别有两个房子 x y ,他们在横坐标上有重叠部分(端点重叠也算),则被称为 “对门” 关系. 问你总共 ...
- springboot使用dubbo和zookeeper
2019-11-17 yls 创建服务接口模块 接口工程只提供接口,不提供实现,在后面的提供者和消费者中使用 在使用接口的模块中只需要写具体实现类,避免了在每个模块中重复编写接口 在接口中引入依赖包 ...
- linux redhat系列后缀为el5,el6,el7软件包的区别
- EL6软件包用于在Red Hat 6.x, CentOS 6.x, and CloudLinux 6.x进行安装 - EL5软件包用于在Red Hat 5.x, CentOS 5.x, Cloud ...
- 【Linux】Debian 下安装 Apache,MySQL,PHP
首先,对你的源进行更新: $ sudo apt-get update 第一步--安装 Apache Apache 是一个开源软件,它目前运行在全球超过 50% 的服务器上,是 LAMP(Linux,A ...
- PHP Laravel5实现的RBAC权限管理操作示例
根据不同的权限,在菜单栏显示不同的功能,只对菜单进行了限制,若对路由也进行限制,可以根据菜单的例子,请自行完善,开发.下面请认真学习一下laravel的RBAC设计 1.建表(用户表.角色表.权限表. ...
- [LC]219题 Contains Duplicate II (存在重复元素 II )
①英文题目: Given an array of integers and an integer k, find out whether there are two distinct indices ...
- ESP8266 智能配网 断电重连
ESP8266 智能配网 断电重连 #include <ESP8266WiFi.h> bool autoConfig() { WiFi.begin(); for (int i = 0; i ...
- fastjason常用方法
背景 fastjson爆出重大漏洞,攻击者可使整个业务瘫痪 漏洞描述 常用JSON组件FastJson存在远程代码执行漏洞,攻击者可通过精心构建的json报文对目标服务器执行任意命令,从而获得服务器权 ...
- 领扣(LeetCode)最长和谐子序列 个人题解
和谐数组是指一个数组里元素的最大值和最小值之间的差别正好是1. 现在,给定一个整数数组,你需要在所有可能的子序列中找到最长的和谐子序列的长度. 示例 1: 输入: [1,3,2,2,5,2,3,7] ...
- 树莓派3B/3B+和4B安装OpenCV教程
安装前准备 在树莓派上拓展文件系统 如果你使用的树莓派为新装的系统,那么第一件事情就是扩展文件系统,以包括microSD卡上的所有空间. 具体步骤如下: 1.在树莓派终端(或者SSH)上输入: $ s ...