POJ 2976 Dropping tests (二分+贪心)】的更多相关文章

题意:给定 n 个分数,然后让你去年 m 个分数,使得把剩下的所有的分子和分母都相加的分数最大. 析:这个题并不是分子越大最后结果就越大,也不是整个分数越大,最后结果就越大的,我们可以反过来理解,要去掉 m 个分数,那么就是要选 n-m个分数, 那么就是 sigma(分子) / sigma(分母) 尽量大,那么最大是多大啊?这个我们可以通过二分来解决,也就是sigma(分子) / sigma(分母) >= x, 因为分子和分母都是正数,所以可以得到 sigma(分子) - sigma(分母)*…
1.题意:同poj3111,给出一组N个有价值a,重量b的物品,问去除K个之后,剩下的物品的平均值最大能取到多少? 2.分析:二分平均值,注意是去除K个,也就是选取N-K个 3.代码: # include <iostream> # include <cstdio> # include <cmath> # include <algorithm> using namespace std; ; ; int N,K; int sgn(double x) { ; )…
最大化平均值 有n个物品的重量和价值分别wi 和 vi.从中选出 k 个物品使得 单位重量 的价值最大. 限制条件: <= k <= n <= ^ <= w_i <= v_i <= ^6 输入:n = 3k = 2{W, V} = {(2,2), (5,3), (2,1)} 输出:0.75 (如果选0号和2号,平均价格是 (2 + 1) / (2 + 2) = 0.75) 题解: 一般先想到的肯定是:把物品按照  单位价值  进行排序,然后从大到小贪心地进行选取.但是这…
POJ - 2976 Dropping tests 你有 \(n\) 次考试成绩, 定义考试平均成绩为 \[\frac{\sum_{i = 1}^{n} a_{i}}{\sum_{i = 1}^{n} b_{i}}\] 你可以考虑放弃 \(K\) 次成绩, 求最大平均成绩 * 100 小插曲: 被精度卡成喜羊羊 0/1分数规划\(from\)人生导师 Solution 01分数规划(不是很)裸题, 在每次 \(check\) 时, 选取较大的 \(num - K + 1\) 次即可 Code #…
题目链接:http://poj.org/problem?id=2976 Dropping tests Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 17838   Accepted: 6186 Description In a certain course, you take n tests. If you get ai out of bi questions correct on test i, your cumula…
Dropping tests   Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 6373   Accepted: 2198 [Description] In a certain course, you take n tests. If you get ai out of bi questions correct on test i, your cumulative average is defined to be . G…
Dropping tests Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 11367   Accepted: 3962 Description In a certain course, you take n tests. If you get ai out of bi questions correct on test i, your cumulative average is defined to be . Give…
Dropping tests Time Limit: 1000MS   Memory Limit: 65536K Total Submissions:17069   Accepted: 5925 Description In a certain course, you take n tests. If you get ai out of bi questions correct on test i, your cumulative average is defined to be . Given…
Dropping tests Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 4654   Accepted: 1587 Description In a certain course, you take n tests. If you get ai out of bi questions correct on test i, your cumulative average is defined to be . Given…
Dropping tests Time Limit: 1000MS Memory Limit: 65536K Description In a certain course, you take n tests. If you get ai out of bi questions correct on test i, your cumulative average is defined to be Given your test scores and a positive integer k, d…