链接:

https://codeforces.com/contest/1230/problem/A

题意:

Dawid has four bags of candies. The i-th of them contains ai candies. Also, Dawid has two friends. He wants to give each bag to one of his two friends. Is it possible to distribute the bags in such a way that each friend receives the same amount of candies in total?

Note, that you can't keep bags for yourself or throw them away, each bag should be given to one of the friends.

思路:

乱搞一下就行, 写了个背包

代码:

#include <bits/stdc++.h>
using namespace std; int a[5], dp[1000];
int sum = 0; int main()
{
for (int i = 1;i <= 4;i++)
cin >> a[i], sum += a[i];
if (sum%2 == 1)
{
puts("NO");
return 0;
}
for (int i = 1;i <= 4;i++)
{
for (int j = sum/2;j >= a[i];j--)
dp[j] = max(dp[j], dp[j-a[i]]+a[i]);
}
if (dp[sum/2] == sum/2)
puts("YES");
else
puts("NO"); return 0;
}

Codeforces Round #588 (Div. 2) A. Dawid and Bags of Candies的更多相关文章

  1. Codeforces Round #588 (Div. 2)-E. Kamil and Making a Stream-求树上同一直径上两两节点之间gcd的和

    Codeforces Round #588 (Div. 2)-E. Kamil and Making a Stream-求树上同一直径上两两节点之间gcd的和 [Problem Description ...

  2. Codeforces Round #588 (Div. 2)

    传送门 A. Dawid and Bags of Candies 乱搞. Code #include <bits/stdc++.h> #define MP make_pair #defin ...

  3. Codeforces Round #588 (Div. 2) E. Kamil and Making a Stream(DFS)

    链接: https://codeforces.com/contest/1230/problem/E 题意: Kamil likes streaming the competitive programm ...

  4. Codeforces Round #588 (Div. 2) D. Marcin and Training Camp(思维)

    链接: https://codeforces.com/contest/1230/problem/D 题意: Marcin is a coach in his university. There are ...

  5. Codeforces Round #588 (Div. 2) C. Anadi and Domino(思维)

    链接: https://codeforces.com/contest/1230/problem/C 题意: Anadi has a set of dominoes. Every domino has ...

  6. Codeforces Round #588 (Div. 2) B. Ania and Minimizing(构造)

    链接: https://codeforces.com/contest/1230/problem/B 题意: Ania has a large integer S. Its decimal repres ...

  7. Codeforces Round #588 (Div. 1)

    Contest Page 因为一些特殊的原因所以更得不是很及时-- A sol 不难发现当某个人diss其他所有人的时候就一定要被删掉. 维护一下每个人会diss多少个人,当diss的人数等于剩余人数 ...

  8. Codeforces Round #588 (Div. 1) 简要题解

    1. 1229A Marcin and Training Camp 大意: 给定$n$个对$(a_i,b_i)$, 要求选出一个集合, 使得不存在一个元素好于集合中其他所有元素. 若$a_i$的二进制 ...

  9. Codeforces Round #588 (Div. 2) D题【补题ING】

    思路:先找出现次数>=2数.然后在取跑所有数,需要考虑一般情况(当一个人比另一个人的ai小且他们的与运算等于小的那个人的ai那么可以知道大的那个人必定强于ai小的那个人). 则可以用位运算实现判 ...

随机推荐

  1. mysql在字符编辑窗口下怎么退出编辑界面?(mysql下的ctrl+c与\c)

    [1]SQL编辑 我们在SQL编辑的时候打错了,想要退出编辑重新输入,或者是不想写了. 如下图 (1)如果我们直接按ctrl+c中断,那么直接退出整个linux了,如上图 (2)我们可以使用\c,直接 ...

  2. Ubuntu18突然卡死解决方法

    emmmm 1.Ctrl+Alt+F2/F3/F4/F5/F6     F2-6随便选一个都可以 2.进入tty终端后先输入用户名和密码(记得小键盘会自动

  3. 火狐 , IE , 谷歌浏览器的 驱动下载地址汇总

    一.Firefox和驱动下载地址 所有火狐浏览器版本下载地址:http://ftp.mozilla.org/pub/firefox/releases/ 所有火狐驱动geckodriver版本下载地址: ...

  4. T100——汇总错误消息显示

    初始化 CALL cl_err_collect_init() 汇总消息显示 CALL cl_err_collect_show()

  5. 【搜索】n的约数

    题目链接:传送门 [题解]: 考察dfs和质因数分解,首先开一个prime数组. 参数解释: 1.当前值的大小.[利用题目的n来控制范围] 2.控制下界,每次都是以某一个质数开始搜索, pos 3.控 ...

  6. SQL Server循环插入

    一个SQL循环插入的代码,运行正常: BEGIN DECLARE @idx AS INT; DECLARE @NodeName nvarchar(255); DECLARE @OtherName nv ...

  7. 如何设置输入IP地址就直接访问到某一个网站

    如何设置输入IP地址就直接访问到某一个网站 1).在IIS中添加好站点后,在网站绑定中设置明确的IP地址,如下图: 2).修改Default WebSite的端口,或者是把Default WebSit ...

  8. winfrom 保存图片

    private void btnSave_Click(object sender, EventArgs e) { SaveFileDialog sfd = new SaveFileDialog(); ...

  9. ORACLE触发器的自治事务的注意事项

    直接上代码: Create OR replace Trigger TR_ROBXMX_CLDJBHHX After INSERT OR UPDATE OR DELETE ON ROBXMX1 --要监 ...

  10. CodeFirst与EntityFramework【续】

    3.    实现一对一的关系.在介绍一对多关系和多对多关系时,大家应该已经注意到了只要存在依赖关系的两个类的定义中包含对方的实例或实例的集合,Entity Framework Code First会自 ...