CodeForces - 1263A Sweet Problem(思维,水题)
题目链接:点击查看
题目大意:给出三种颜色的糖果,分别表示为r,g,b,现在Tanya每天可以吃两个不同颜色的糖果,问最多可以吃多少天
题目分析:大水题一个,但自己真的蠢,一开始思路混乱,写了一大堆乱七八糟的,肯定是以WA首尾
只需要简单分类讨论一下就行了,首先对于三个数值排序,我们记为mmin,mid和mmax:
- 若mmin+mid<mmax,则答案为mmin+mid,即mmin和mid每个都去和mmax匹配
- 若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(思维,水题)相关推荐
- CodeForces - 29A Spit Problem【水题】
题目链接:https://codeforces.com/contest/29/problem/A #include <iostream> #include <cstdio> # ...
- 【Disturbed People】【CodeForces - 1077B】(思维水题)
题目: There is a house with nn flats situated on the main street of Berlatov. Vova is watching this ho ...
- codeforces 1060a(思维水题)
Let's call a string a phone number if it has length 11 and fits the pattern "8xxxxxxxxxx", ...
- FZU 2230 2230 翻翻棋(思维水题)
Problem Description 象棋翻翻棋(暗棋)中双方在4*8的格子中交战,有时候最后会只剩下帅和将.根据暗棋的规则,棋子只能上下左右移动,且相同的级别下,主动移动到地方棋子方将吃掉对方的棋 ...
- CF Round #426 (Div. 2) The Useless Toy 思维 水题
题目链接: http://codeforces.com/contest/834/problem/A 题目描述: 输入起始状态和结束状态和数列长度, 判断旋转方向是顺时针逆时针还是不合理 解题思路: 长 ...
- Codeforces 864 A Fair Game 水题
题目链接: http://codeforces.com/problemset/problem/864/A 题目描述: 看不是是不是一串数中只有两种数且这两种数字的数量是相同的 解题思路: 水题, 水过 ...
- CodeForces - 1141D Colored Boots(暴力+水题)
题目链接:点击查看 题目大意:给出两个字符串s和t,两个字符串中相同的字母可以匹配,问号可以和任意字符匹配,现在问两个字符串最多能匹配多少个字符,并给出匹配的下标 题目分析:挺好玩的一道水题,大体思路 ...
- 【CodeForces - 569B】Inventory (水题)
题干: Companies always have a lot of equipment, furniture and other things. All of them should be trac ...
- codeforces 702A A. Maximum Increase(水题)
题目链接: A. Maximum Increase time limit per test 1 second memory limit per test 256 megabytes input sta ...
最新文章
- [开发笔记]-jQuery获取radio选中项的值
- ldap 高级查询 禁用_化妆水有治疗耳部疾患、痔疮等11大功效?专家表示或含禁用物质...
- 用python画玫瑰花教程-利用Python的turtle库绘制玫瑰教程
- Java 反射 不定参数bug
- python中requests的常用方法_Python爬虫简介(2)——请求库的常用方法及使用,python,入门,二,requests,常见,和,库中,文官,网...
- ORA-12170: TNS:Connect timeout occurred
- spring cloud eureka 服务之间调用_Spring-cloud微服务实战【一】:微服务的概念与演进过程...
- 电脑显示苹果5s未连接服务器怎么办啊,iphone5s数据线连接不上电脑怎么办【解决方法】...
- ASP.Net新手项目经验谈
- 谷歌Pixel 4“浴霸”相机模组细节曝光:包含一枚长焦镜头
- 老板看似表面风光,可能还没有员工赚得多
- 定时任务 Wpf.Quartz.Demo.3
- 通达信插件模板 Purebasic版
- php中 不等运算符是,PHP中,不等运算符是
- 《猎罪图鉴》中暴露出人脸识别安全隐患,你的脸或许正被仿冒
- 让我们愉快的切割吧 - 4:如何在无特定间隔符下拆分字母和数字
- avcodec_receive_frame
- 为什么4个反斜杠(\)输出1个反斜杠(\)?
- const指针的一些总结
- leaflet 降雨等值面的动画效果