UvaLive 4863 Balloons(贪心)】的更多相关文章

There will be several test cases in the input. Each test case will begin with a line with three integers: N A B Where N is the number of teams (1N1, 000), and A and B are the number of balloons in rooms A and B, respectively (0A, B10, 000). On each o…
题意: 给定n个队伍, 然后A房间有a个气球, B房间有b个气球, 然后给出每个队伍所需要的气球数量和到A B房间的距离, 求把气球全部送到每个队伍的最短距离. 分析: 在气球充足的情况下, 那么我们对于每个队伍, 肯定是哪个房间近就取哪个房间的气球. 但是题目中气球的数目有限, 所以很有可能出现某个时刻第i个队伍到A比较近, 但是A没有气球了, 只能去B拿的这种情况.这样的损失就是他们的距离差. 所以猜想是先把到A和到B距离差较大的队伍先满足了, 这样就能降低损失, 有这种贪心的思想应该就能求…
[题目] There are a number of spherical balloons spread in two-dimensional space. For each balloon, provided input is the start and end coordinates of the horizontal diameter. Since it's horizontal, y-coordinates don't matter and hence the x-coordinates…
题目链接:codeforces 725D . Contest Balloons 先按气球数从大到小排序求出初始名次,并把名次排在第一队前面的队放入优先队列,按w-t-1值从小到大优先,然后依次给气球给排名在前面的的队,给完后自己的气球数减少,继续跟之前排在第一队后面的队比较,考虑是否加入队列,每次记录最好的名次. #include<cstdio> #include<cstring> #include<algorithm> #include<queue> us…
Let x1, x2,..., xm be real numbers satisfying the following conditions: a) -xi ; b) x1 + x2 +...+ xm = b *  for some integers  a and  b  (a > 0). Determine the maximum value of xp1 + xp2 +...+ xpm for some even positive integer p. Input Each input li…
题目连接:2911 - Maximum 题目大意:给出m, p, a, b,然后xi满足题目中的两个公式, 要求求的 xp1 + xp2 +...+ xpm 的最大值. 解题思路:可以将x1 + x2 +...+ xm = b *  两端同时乘以根号a去计算.然后按照贪心的思想去计算. #include <stdio.h> #include <math.h> int l, r; double m, p, a, b, tmp, sum; int main() { while (sca…
题目链接:https://vjudge.net/contest/244167#problem/F 题目: Given any integer base b ≥ 2, it is well known that every positive integer n can be uniquely represented in base b. That is, we can write n = a0 + a1 ∗b + a2 ∗b∗b + a3 ∗b∗b∗b + ... where the coeffi…
题目链接  题意 工程师要安装n个服务,其中服务Ji需要si单位的安装时间,截止时间为di.超时会有惩罚值,若实际完成时间为ci,则惩罚值为max{0,ci-di}.从0时刻开始执行任务,问惩罚值最大的两个服务的惩罚值之和的最小是多少? 分析 乍一看似乎要二分,但实际上并不是.贪心来做,按di从小到大安排任务,当di相等时,让完成时间短的排前,这样安排任务一定时更优的,但是并不能满足题目的要求.于是需要从两个最大惩罚值的前面挑选一个任务,并将它放置在后面,然后更新答案即可. #include<c…
          D. Contest Balloons          time limit per test 3 seconds         memory limit per test 256 megabytes input standard input output standard output One tradition of ACM-ICPC contests is that a team gets a balloon for every solved problem. We…
UVALive - 6268 Cycling 题意:从一端走到另一端,有T个红绿灯,告诉你红绿灯的持续时间,求最短的到达终点的时间.x 思路:…