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! [ ...
随机推荐
- 创建基于OData的Web API - Knowledge Builder API, Part II:Project Setup
本篇为Part II:Project Setup 查看第一篇<Part I: Business Scenario> 第一步,准备步骤. 准备步骤一,下载.NET Core 2.2 SDK ...
- (C#)WPF:关于INotifyPropertyChanged接口的介绍
注意:INotifyPropertyChanged接口位于System.CompenentModel名称空间中,想使用INotifyPropertyChanged接口时,头文件需添加“using Sy ...
- stdClass Object 数据的处理
stdClass Object 数据的处理 在调用接口的时候往往返回的是 stdClass Object 类型的数据,我们在取数据值的时候就阔以直接使用对象->属性值的方式操作值 $ret = ...
- nyoj 24-素数距离问题 (素数算法)
24-素数距离问题 内存限制:64MB 时间限制:3000ms Special Judge: No accepted:21 submit:71 题目描述: 现在给出你一些数,要求你写出一个程序,输出这 ...
- 【Leetcode 做题学算法周刊】第四期
首发于微信公众号<前端成长记>,写于 2019.11.21 背景 本文记录刷题过程中的整个思考过程,以供参考.主要内容涵盖: 题目分析设想 编写代码验证 查阅他人解法 思考总结 目录 67 ...
- 【前端知识体系-CSS相关】Bootstrap相关知识
1.Bootstrap 的优缺点? 优点:CSS代码结构合理,现成的代码可以直接使用(响应式布局) 缺点:定制流程较为繁琐,体积大 2.如何实现响应式布局? 原理:通过media query设置不同分 ...
- robatframework+jenkins+email集成部署方案
准备工作: 1.jenkins.war包 下载地址:https://jenkins.io/zh/download/ 2.Jdk1.8 下载地址:http://www.oracle.com/techne ...
- 继上篇-jquery ajax提交 本篇用ajax提交的数据去数据库查询
上篇讲到如何用jquery ajax提交数据至后台,后台接收并返回给ajax.https://www.cnblogs.com/tiezhuxiong/p/11943328.html 今天我们把数据传到 ...
- 记一次net/net core delete 方法报404 解决方案
今天一个net core的delete方法 执行的时候 报404 网上查阅资料后发现是IIS 默认只允许get/post方法接入 网上查找资料后 在web.config添加如下代码: 意为移除WebD ...
- python爬虫项目-一见倾心壁纸
方法1 import re import urllib import urllib.request def getHtml(url): page = urllib.request.urlopen(ur ...