Codeforces Round #588 (Div. 2) A. Dawid and Bags of Candies
链接:
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的更多相关文章
- 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 ...
- Codeforces Round #588 (Div. 2)
传送门 A. Dawid and Bags of Candies 乱搞. Code #include <bits/stdc++.h> #define MP make_pair #defin ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- Codeforces Round #588 (Div. 1)
Contest Page 因为一些特殊的原因所以更得不是很及时-- A sol 不难发现当某个人diss其他所有人的时候就一定要被删掉. 维护一下每个人会diss多少个人,当diss的人数等于剩余人数 ...
- Codeforces Round #588 (Div. 1) 简要题解
1. 1229A Marcin and Training Camp 大意: 给定$n$个对$(a_i,b_i)$, 要求选出一个集合, 使得不存在一个元素好于集合中其他所有元素. 若$a_i$的二进制 ...
- Codeforces Round #588 (Div. 2) D题【补题ING】
思路:先找出现次数>=2数.然后在取跑所有数,需要考虑一般情况(当一个人比另一个人的ai小且他们的与运算等于小的那个人的ai那么可以知道大的那个人必定强于ai小的那个人). 则可以用位运算实现判 ...
随机推荐
- gRPC安装的小问题
INSTALL.md提到下述前提条件 #Pre-requisites ##Linux ```sh $ [sudo] apt-get install build-essential autoconf l ...
- Git Bash输错账号密码如何重新输入
很多时候我们容易在Git Bash操作的时候,不慎输入错误的用户名或密码,此时一直提示: remote: Incorrect username or password ( access token ) ...
- ibox 的使用
<div class="ibox float-e-margins"> <div class="ibox-title"> <h5&g ...
- SQL SERVER创建表
创建表 create table table_name ( column_name_1 data_type, column_name_2 data_type NOT NULL, column_name ...
- Linux系列(16)之系统资源的观察
1.系统资源观察 1.观察内存使用情况:free 格式: free //默认显示的单位为KBytes,显示系统的内存容量 free [-b | -k | -m | -g | -h] [-t] [ ...
- 剑指offer42:数组和一个数字S,输出两个数的乘积最小的
1 题目描述 输入一个递增排序的数组和一个数字S,在数组中查找两个数,使得他们的和正好是S,如果有多对数字的和等于S,输出两个数的乘积最小的. 输出描述: 对应每个测试案例,输出两个数,小的先输出. ...
- # Ubuntu子系统安装配置
目录 Ubuntu子系统安装配置 安装配置 终端美化 卸载 和win10之间的交互 Ubuntu子系统安装配置 亲测启动速度毫秒之间 安装配置 系统升级到一周年正式版及以上(1607) 依次在 设置 ...
- C++ 继承 - 在派生类中对基类初始化
构造函数与基类的其他成员不同,不能被派生类继承,因此为了初始化基类中的成员变量,需要在派生类中调用基类的构造函数(即显式调用),如果派送类没有调用则默认调用基类的无参构造函数(即隐式调用). 显式调用 ...
- sublime 配置大全
最近玩 python ,一般用的编译器是 pycharm ,功能强大,但是苦于启动速度遂准备换坑,瞄上了 sublime .这里记录一下 sublime 的设置以及坑爹项,需要注意的是我用的是 sub ...
- 【css】display:flex和display:box有什么区别
说法一: 注意:前者是flex 2012年的语法,也将是以后标准的语法,大部分浏览器已经实现了无前缀版本.后者是2009年的语法,已经过时,是需要加上对应前缀的.所以兼容性的代码,大致如下displa ...