UVALive 7464 Robots (贪心)】的更多相关文章

Robots 题目链接: http://acm.hust.edu.cn/vjudge/contest/127401#problem/K Description http://7xjob4.com1.z0.glb.clouddn.com/168817810b54cfa4ffaebf73d3d1b0c5 Input The input consists of multiple test cases. First line contains a single integer t indicating…
7464Robots Write a program to collect data from robots. We are given two sets of robotsX=fX1;:::;Xmg,Y=fY1;:::;Yng, and a baseB. Each robot has a data and we would like to compute the sum of datafrom all robots and deliver it to the base. In order to…
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…
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…
UVALive - 6268 Cycling 题意:从一端走到另一端,有T个红绿灯,告诉你红绿灯的持续时间,求最短的到达终点的时间.x 思路:…
这个题首先要利用题目的特性,先贪心,否则无法进行DP 因为求期望的话,越后面的乘的越大,所以为了得到最小值,应该把概率值降序排序,把大的数跟小的系数相乘 然后这种dp的特性就是转移的时候,由 i推到i+1每次添加一个数,就要考虑这个新数应该和谁放在一组,枚举他放在哪一组即可 dp[i][j]代表当前第i个数有j个分组时候的最小值 dp[i][j]=dp[k][j-1]+i(prefix[i]-prefix[k-1]),k代表枚举第几个数开始和当前新添加的数为一组,prefix为前缀和,为了迅速得…
VJ题目链接 题意:平面上有n个点,在x轴上放一些点,使得平面上所有点都能找到某个x轴上的点,使得他们的距离小于d.求最少放几个点. 思路:以点为中心作半径为d的圆,交x轴为一个线段.问题转换成用最少的店覆盖所有的线段.经典贪心.按右点从小到大排序,然后从左往右扫,每次选择区间右点就行了. 代码: #include <cstdio> #include <cstring> #include <cmath> #include <algorithm> using…