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小的那个人). 则可以用位运算实现判 ...
随机推荐
- SQL语句中的HAVING关键字
sql中的having语句是在使用group by的时候使用的. 通常where语句是在group by之前做数据筛选的,而having语句是对group by之后的结果进行筛选的. 例如: 从商品销 ...
- Codeforces Round #590 (Div. 3)补题
要想上2000分,先刷几百道2000+的题再说 ---某神 题目 E F 赛时是否尝试 × × tag math bitmask 难度 2000 2400 状态 ∅ √ 解 E 待定 F 传送门 第一 ...
- 【Python】**kwargs和takes 1 positional argument but 2 were given
Python的函数定义中可以在参数里添加**kwargs——简单来说目的是允许添加不定参数名称的参数,并作为字典传递参数.但前提是——你必须提供参数名. 例如下述情况: class C(): def ...
- selenium登录百度
from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.s ...
- go的命令行参数
package main import ( "fmt" "os" ) func main() { var s, sep string for i := 1; i ...
- 设计模式风格<一>;回调风格
主程序,是一个人,有一个类是同事: static void Main(string[] args) { Console.WriteLine("Hello Go to Lunch?" ...
- vue 父子组件数据的双向绑定大法
官方文档说明 所有的 prop 都使得其父子 prop 之间形成了一个 单向下行绑定 父级 prop 的更新会向下流动到子组件中,但是反过来则不行 2.3.0+ 新增 .sync 修饰符 以 upda ...
- IOI2020只因训队作业胡做
w a r n i n g ! 意 识 流 警 告 !!1 不想一个个发了,干脆直接发个合集得了qwq 感觉这辈子都做不完了\(Q\omega Q\) CF516D 写过题解了 CF505E 写过题解 ...
- Navicat for MySQL 设置定时任务(事件)
1.查询界面输入命令,查看定时任务是否开启,未开始时OFF: show variables like '%event_scheduler%'; 2. 查询界面输入命令,开启定时任务: set glob ...
- ESP8266 UDP通信
#include "driver/uart.h" #include "espconn.h" void ICACHE_FLASH_ATTR user_rf_pre ...