明明是一道很裸的“最大值最小”的二分题,考试时硬是没想到OTZ...
Time Limit: 2 sec / Memory Limit: 1024 MB
Score: 500 points
Takahashi will take part in an eating contest. Teams of N
members will compete in this contest, and Takahashi's team consists of N players numbered 1 through N from youngest to oldest. The consumption coefficient of Member i is Ai.
In the contest, N foods numbered 1 through N will be presented, and the difficulty of Food i is Fi. The details of the contest are as follows:
A team should assign one member to each food, and should not assign the same member to multiple foods.It will take x×y seconds for a member to finish the food, where x is the consumption coefficient of the member and y is the difficulty of the dish.The score of a team is the longest time it takes for an individual member to finish the food.Before the contest, Takahashi's team decided to do some training. In one set of training, a member can reduce his/her consumption coefficient by 1, as long as it does not go below 0. However, for financial reasons, the N members can do at most Ksets of training in total.
What is the minimum possible score of the team, achieved by choosing the amounts of members' training and allocating the dishes optimally?
Input is given from Standard Input in the following format:
Print the minimum possible score of the team.
They can achieve the score of 2, as follows:
Member 1 does 4 sets of training and eats Food 2 in (4−4)×3=0seconds.Member 2 does 1 set of training and eats Food 3 in (2−1)×1=1second.Member 3 does 0 sets of training and eats Food 1 in (1−0)×2=2seconds.They cannot achieve a score of less than 2, so the answer is 2They can choose not to do exactly K sets of training.
有n个人和n份食物,每个人吃东西的系数为ai,食物被吃的系数为fi,一个人吃一份食物,所花时间为 ai * fi,求所有人各吃一份食物,所有人中吃食物所花的最大时间最小
首先【贪心】地想:人的系数小的去吃食物系数大的,反之亦然,所以可以先把a[ ]按从小到大排序,f[ ]从大到小排序
【最大值最小】,典型的二分的题型
从0到a范围的最大值二分所花的最大的时间x,检查能否使每个ai*fi都小于等于x
分析完感觉还是挺水的
自己有另一种想法,只是还未实现:
直接在a数组上二分