题目链接:点击查看

题目大意:给出三种颜色的糖果,分别表示为r,g,b,现在Tanya每天可以吃两个不同颜色的糖果,问最多可以吃多少天

题目分析:大水题一个,但自己真的蠢,一开始思路混乱,写了一大堆乱七八糟的,肯定是以WA首尾

只需要简单分类讨论一下就行了,首先对于三个数值排序,我们记为mmin,mid和mmax:

  1. 若mmin+mid<mmax,则答案为mmin+mid,即mmin和mid每个都去和mmax匹配
  2. 若mmin+mid>=mmax,则答案为(mmax+mmin+mid)/2,因为不存在某一种糖果会剩下过多的自己导致无法匹配,所以尽可能的多匹配就好了

代码:

#include<iostream>
#include<cstdlib>
#include<string>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cctype>
#include<stack>
#include<queue>
#include<list>
#include<vector>
#include<set>
#include<map>
#include<sstream>
using namespace std;typedef long long LL;const int inf=0x3f3f3f3f;const int N=2e5+100;int a[5];int main()
{
//  freopen("input.txt","r",stdin);
//  ios::sync_with_stdio(false);int w;cin>>w;while(w--){for(int i=1;i<=3;i++)scanf("%d",a+i);sort(a+1,a+1+3);if(a[1]+a[2]<a[3])printf("%d\n",a[1]+a[2]);elseprintf("%d\n",(a[1]+a[2]+a[3])/2);}return 0;
}

CodeForces - 1263A Sweet Problem(思维,水题)相关推荐

  1. CodeForces - 29A Spit Problem【水题】

    题目链接:https://codeforces.com/contest/29/problem/A #include <iostream> #include <cstdio> # ...

  2. 【Disturbed People】【CodeForces - 1077B】(思维水题)

    题目: There is a house with nn flats situated on the main street of Berlatov. Vova is watching this ho ...

  3. codeforces 1060a(思维水题)

    Let's call a string a phone number if it has length 11 and fits the pattern "8xxxxxxxxxx", ...

  4. FZU 2230 2230 翻翻棋(思维水题)

    Problem Description 象棋翻翻棋(暗棋)中双方在4*8的格子中交战,有时候最后会只剩下帅和将.根据暗棋的规则,棋子只能上下左右移动,且相同的级别下,主动移动到地方棋子方将吃掉对方的棋 ...

  5. CF Round #426 (Div. 2) The Useless Toy 思维 水题

    题目链接: http://codeforces.com/contest/834/problem/A 题目描述: 输入起始状态和结束状态和数列长度, 判断旋转方向是顺时针逆时针还是不合理 解题思路: 长 ...

  6. Codeforces 864 A Fair Game 水题

    题目链接: http://codeforces.com/problemset/problem/864/A 题目描述: 看不是是不是一串数中只有两种数且这两种数字的数量是相同的 解题思路: 水题, 水过 ...

  7. CodeForces - 1141D Colored Boots(暴力+水题)

    题目链接:点击查看 题目大意:给出两个字符串s和t,两个字符串中相同的字母可以匹配,问号可以和任意字符匹配,现在问两个字符串最多能匹配多少个字符,并给出匹配的下标 题目分析:挺好玩的一道水题,大体思路 ...

  8. 【CodeForces - 569B】Inventory (水题)

    题干: Companies always have a lot of equipment, furniture and other things. All of them should be trac ...

  9. codeforces 702A A. Maximum Increase(水题)

    题目链接: A. Maximum Increase time limit per test 1 second memory limit per test 256 megabytes input sta ...

最新文章

  1. [开发笔记]-jQuery获取radio选中项的值
  2. ldap 高级查询 禁用_化妆水有治疗耳部疾患、痔疮等11大功效?专家表示或含禁用物质...
  3. 用python画玫瑰花教程-利用Python的turtle库绘制玫瑰教程
  4. Java 反射 不定参数bug
  5. python中requests的常用方法_Python爬虫简介(2)——请求库的常用方法及使用,python,入门,二,requests,常见,和,库中,文官,网...
  6. ORA-12170: TNS:Connect timeout occurred
  7. spring cloud eureka 服务之间调用_Spring-cloud微服务实战【一】:微服务的概念与演进过程...
  8. 电脑显示苹果5s未连接服务器怎么办啊,iphone5s数据线连接不上电脑怎么办【解决方法】...
  9. ASP.Net新手项目经验谈
  10. 谷歌Pixel 4“浴霸”相机模组细节曝光:包含一枚长焦镜头
  11. 老板看似表面风光,可能还没有员工赚得多
  12. 定时任务 Wpf.Quartz.Demo.3
  13. 通达信插件模板 Purebasic版
  14. php中 不等运算符是,PHP中,不等运算符是
  15. 《猎罪图鉴》中暴露出人脸识别安全隐患,你的脸或许正被仿冒
  16. 让我们愉快的切割吧 - 4:如何在无特定间隔符下拆分字母和数字
  17. avcodec_receive_frame
  18. 为什么4个反斜杠(\)输出1个反斜杠(\)?
  19. const指针的一些总结
  20. leaflet 降雨等值面的动画效果

热门文章

  1. Elastic-Job简介
  2. Channel 与ChannelPipeline
  3. Nacos配置中心-加载多配置集
  4. ReactJS入门之组件状态
  5. Eureka集群部署
  6. Redisson框架框架集成
  7. c语言怎么减去一个16进制数,一个简单的有关问题:像这样的16进制数怎么转换得到...
  8. OAuth2(二)——实现
  9. ReentrantReadWriteLock源码解析
  10. php 微信机器人_微信小程序机器人自动客服功能