Mike and distribution】的更多相关文章

D. Mike and distribution time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Mike has always been thinking about the harshness of social inequality. He's so obsessed with it that sometimes it…
D. Mike and distribution time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Mike has always been thinking about the harshness of social inequality. He's so obsessed with it that sometimes it…
http://codeforces.com/contest/798/problem/D D. Mike and distribution time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Mike has always been thinking about the harshness of social inequality.…
题目链接 Mike and distribution 题目意思很简单,给出$a_{i}$和$b_{i}$,我们需要在这$n$个数中挑选最多$n/2+1$个,使得挑选出来的 $p_{1}$,$p_{2}$,$p_{3}$,...,$p_{m}$满足 $a_{p1}+a_{p2}+a_{p3}+...+a_{p_{m}}>a_{1}+a_{2}+a_{3}+...+a_{n}$ $b_{p1}+b_{p2}+b_{p3}+...+b_{p_{m}}>b_{1}+b_{2}+b_{3}+...+b_…
/* CF410div2 D. Mike and distribution http://codeforces.com/contest/798/problem/D 构造 题意:给出两个数列a,b,求选出n/2+1个数对,使得其和的二倍大于各自的数列 思路:对数列a进行排序,因为可以选一半加1个,所以最大的那个我们选出来 然后在剩下的数列中,每隔两个选则b中较大的, 这样可以保证选出的在b中满足条件,并且在a中也满足条件 然而....我他喵的居然忘了读入b数列!!!! */ #include <c…
CF798D Mike and distribution 洛谷评测传送门 题目描述 Mike has always been thinking about the harshness of social inequality. He's so obsessed with it that sometimes it even affects him while solving problems. At the moment, Mike has two sequences of positive in…
Mike has always been thinking about the harshness of social inequality. He's so obsessed with it that sometimes it even affects him while solving problems. At the moment, Mike has two sequences of positive integers A = [a1, a2, ..., an] and B = [b1, …
http://codeforces.com/contest/798/problem/D http://blog.csdn.net/yasola/article/details/70477816 对于二维的贪心我们可以先让它变成其中一维有序,这样只需要重点考虑另一维,就会简单很多. 首先,对于题目要求的选择元素之和两倍大与所有元素之和,我们可以转化为选择元素之和大于剩下的.然后我们可以将下标按照a从大到小排序.然后选择第一个,之后每两个一组,选择b大的一个,如果n是偶数再选择最后一个. 至于这样写…
题目链接 TAG: 这是我近期做过最棒的一道贪心思维题,不容易想到,想到就出乎意料. 题意:给定两个含有N个正整数的数组a和b,让你输出一个数字k ,要求k不大于n/2+1,并且输出k个整数,范围为1~n的不重复数字, 要求这k个数字为下标的对应a和b中的数的和乘以2的值  分别大于a和b 的数组总和. 思路:首先对a进行降序排序,然后输出最大值的下标,随后进行幅度为2的枚举,对排序后的a2~an进行选择性输出下标,(注意,排序的时候用一个新数组开两个变量,一个index,一个v进行排序,可以用…
题目链接 题目大意 给定两个序列a,b,要求找到不多于个下标,使得对于a,b这些下标所对应数的2倍大于所有数之和. N<=100000,所有输入大于0,保证有解. 因为明确的暗示,所以一定找个. 考虑去掉取整符号,分奇偶讨论. 1 n为奇数 将a从大到小排序,首先取最大的,接着每两个数取其中b较大的. 2 n为偶数 将a从大到小排序,首先取最大的和另一个(都可以),接着每两个数取其中b较大的. #include<algorithm> #include<iostream> #i…