CodeForces 489B BerSU Ball (贪心)】的更多相关文章

BerSU Ball 题目链接: http://acm.hust.edu.cn/vjudge/contest/121332#problem/E Description The Berland State University is hosting a ballroom dance in celebration of its 100500-th anniversary! n boys and m girls are already busy rehearsing waltz, minuet, po…
B. BerSU Ball time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output The Berland State University is hosting a ballroom dance in celebration of its 100500-th anniversary! n boys and m girls are al…
题目链接:http://codeforces.com/problemset/problem/489/B 题目意思:给出 n 个 boys 的 skills 和 m 个 girls 的 skills,要求成 pair 的条件为,男和女的 skill 差值最多只能为 1.问成 pair 最多是多少. 这个不太难,关键是要考虑周全. 对于某个人,假设他(男)的 skill 值为 i,那么跟他成 pair 的人的 skill 值,只有三种:i-1,i,i+1.跟他成对的女要减少一个.然后女的那边也要搜一…
BerSU Ball time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output The Berland State University is hosting a ballroom dance in celebration of its 100500-th anniversary! n boys and m girls are alrea…
B. BerSU Ball time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output The Berland State University is hosting a ballroom dance in celebration of its 100500-th anniversary! n boys and m girls are al…
http://codeforces.com/problemset/problem/489/B B. BerSU Ball time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output The Berland State University is hosting a ballroom dance in celebration of its 1…
B. BerSU Ball time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output The Berland State University is hosting a ballroom dance in celebration of its 100500-th anniversary! n boys and m girls are al…
codeforces 704B - Ant Man 贪心 题意:n个点,每个点有5个值,每次从一个点跳到另一个点,向左跳:abs(b.x-a.x)+a.ll+b.rr 向右跳:abs(b.x-a.x)+a.lr+b.rl,遍历完所有的点,问你最后的花费是多少 思路:每次选一个点的时候,在当前确定的每个点比较一下,选最短的距离. 为什么可以贪心?应为答案唯一,那么路径必定是唯一的,每个点所在的位置也一定是最短的. #include <bits/stdc++.h> using namespace…
CodeForces - 50A Domino piling (贪心+递归) 题意分析 奇数*偶数=偶数,如果两个都为奇数,最小的奇数-1递归求解,知道两个数都为1,返回0. 代码 #include <iostream> #include <cstdio> #include <algorithm> #include <cstring> #include <sstream> #include <set> #include <map…
题意: 有m个男孩和n个女孩,每个人都有一个舞蹈熟练度,用一个不超过100的正整数来表示. 一个男孩和一个女孩能够结为舞伴当且仅当两人的熟练度相差不超过1. 问最多能结成多少对舞伴 分析: 这是一个二分图最大匹配问题,如果男孩和女孩满足条件则添加一条边,然后用匈牙利算法求最大匹配即可. 这是匈牙利算法的模板 http://www.cnblogs.com/AOQNRMGYXLMV/p/3950653.html 题解中还给了一种贪心的解法.将两边的熟练度排序,然后匹配. #include <cstd…