一.题面 POJ2010 二.分析 堆预处理 首先可以考虑吧随便取一个点,判断两侧的最小的总费用是多少,然后相加判断是否满足条件.如果直接判断会超时,所以需要用大根堆预处理一下.先看从分数最小的往最大的预处理,先取N/2个相加,并把他们都加入到堆中,先假设这个和值是最大的,然后不断往后扫描的过程中,不断更新大根堆的根值,以及它的和.反向预处理类似.比较容易出错的是选的范围,如果不用那些不可能到的点,可以随意点,但如果需要使用这些点,需要用足够大的值填充. 三.AC代码 #include <cst…
Moo University - Financial Aid 其实是老题了http://www.cnblogs.com/Philip-Tell-Truth/p/4926008.html 这一次我们换二分法来做这一道题,其实二分法比我以前那个方法好想一点,主要是这次我们可以根据下标进行二分,然后排两次序,第一次是根据分数来排序,然后记录分数的序,接下来就把aid排一次序,然后我们就可以进行二分了 参考http://www.hankcs.com/program/cpp/poj-2010-moo-un…
Moo University - Financial Aid Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 6020 Accepted: 1792 Description Bessie noted that although humans have many universities they can attend, cows have none. To remedy this problem, she and her fe…
                                                                                            Moo University - Financial Aid Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 7961   Accepted: 2321 Description Bessie noted that although human…
POJ 2010 Moo University - Financial Aid 题目大意,从C头申请读书的牛中选出N头,这N头牛的需要的额外学费之和不能超过F,并且要使得这N头牛的中位数最大.若不存在,则输出-1(一开始因为没看见这个,wa了几次). 这个题的第一种做法就是用两个优先队列+贪心. /* * Created: 2016年03月27日 14时41分47秒 星期日 * Author: Akrusher * */ #include <cstdio> #include <cstdl…
Moo University - Financial Aid Descriptions 奶牛大学:奶大招生,从C头奶牛中招收N(N为奇数)头.它们分别得分score_i,需要资助学费aid_i.希望新生所需资助不超过F,同时得分中位数最高.求此中位数. Input *第1行:三个以空格分隔的整数N,C和F *第2..C + 1行:每行两个以空格分隔的整数.首先是小牛的CSAT分数; 第二个整数是小牛所需的经济援助金额 Output *第1行:一个整数,即Bessie可以达到的最大中位数分数.如果…
Moo University - Financial Aid Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 6599   Accepted: 1926 Description Bessie noted that although humans have many universities they can attend, cows have none. To remedy this problem, she and he…
Description Bessie noted that although humans have many universities they can attend, cows have none. To remedy this problem, she and her fellow cows formed a new university called The University of Wisconsin-Farmside,"Moo U" for short. Not wish…
Description Bessie noted that although humans have many universities they can attend, cows have none. To remedy this problem, she and her fellow cows formed a new university called The University of Wisconsin-Farmside,"Moo U" for short. Not wish…
考虑到数据结构短板严重,从计算几何换换口味= = 二叉堆 简介 堆总保持每个节点小于(大于)父亲节点.这样的堆被称作大根堆(小根堆). 顾名思义,大根堆的数根是堆内的最大元素. 堆的意义在于能快速O(1)找到最大/最小值,并能持续维护. 复杂度 push() = O(logn); pop() = O(logn); BinaryHeap() = O(nlogn); 实现 数组下标从1开始的情况下,有 Parent(i) = i >> 1 LChild(i) = i << 1 RChi…