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…
题目地址 分析:如果用二分法,关键是score和aid分开排序,score排序是为了充分利用中位数的性质,这样就可以确定m左右必须各选N/2个,到这之后有人是用dp求最优解,可以再次按照aid排序一次,可以直接确定最优解(肯定是从最小的开始选择!): #include <cstdio> #include <algorithm> #include <cstring> using namespace std; int N, C, F; ; struct Cow{ int i…
题意的话,就看其他人的吧 概括:二分中位数 大体上便是二分一个中位数,带入检验,若分数比他小的有\(\lfloor n/2 \rfloor\)个,分数比他的大的也有这么多,而且贪心的买,花费小于预算. 便带入到数作为中位数是可以的.记录并进行下一次二分 #include<cstdio> #include<algorithm> #include<iostream> #include<cstring> using std::sort; const int max…
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 其实是老题了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…
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…