Gym 101341C Urn with Balls 签到

来源:互联网 发布:宝马五系轮毂数据 编辑:程序博客网 时间:2024/05/16 15:39

题目链接:点我

题目大意:给你a个红球,b个绿球,c个未知颜色的球,要求拿出的的球红球不能超过n个,绿球不能超过m个,问最多能拿多少个出来。

简单分一下类即可,卧槽,这种题目,我现场居然没想出来,真的菜。

分类情况见代码

AC代码:

/*2017年8月13日21:52:43AC水题签到 */ #include <iostream>#include <map>#include <set>#include <string>#include <cstring>#include <cstdio>#include <algorithm>#include <cmath>#include <queue>using namespace std;typedef long long ll;ll a,b,c,n,m;int main(){ scanf("%lld%lld%lld%lld%lld",&a,&b,&c,&n,&m); if(a+c>n&&b+c>m) printf("%lld\n",min(n,m)); else if(a+c>n&&b+c<=m) printf("%lld\n",n); else if(a+c<=n&&b+c>m) printf("%lld\n",m); else if(a+c<=n&&b+c<=m) printf("%lld\n",a+b+c);return 0;}