vj题目链接

题意:

有n (n<16345)个人,每个人有三个数(小于1000且最多两位小数点),表示答对对应题的得分。规定总分越高的人rank越高。总分相同,id小的rank高。现在知道rank,问这个rank是否可能,如果可能,那么rank最小的那个人的最大得分是多少。

思路:

3个数,最多8种情况。然后从rank小往上推,每次选择一个最小的能符合条件的分数,当作这个人的分数。如果能推下去,则ok,否则,不能。

坑点:

精度很坑。转成整数才过了。

代码:

#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std; #define N 20000 struct Man{
int a[];
int possible[];
void read() {
for (int i = ; i < ; i++) {
double tmp;
scanf("%lf", &tmp);
a[i] = (int)((tmp+1e-)*);
}
for (int i = ; i < ; i++) {
int sum = ;
for (int j = ; j < ; j++) {
if ((i>>j)&) {
sum += a[j];
}
}
possible[i] = sum;
}
sort(possible, possible+);
}
}man[N];
int rk[N];
int n; bool dfs(int pre, int id) {
if (id <= ) return true;
int minres = 0x3f3f3f3f;
bool isok = false;
for (int i = ; i >= ; i--) {
if (man[rk[id]].possible[i] > pre || (man[rk[id]].possible[i] == pre && rk[id] < rk[id+])) {
isok = true;
minres = min(minres, man[rk[id]].possible[i]);
} else break;
}
if (!isok) return false; return dfs(minres, id-);
} int main() {
int cas = ;
while (scanf("%d", &n)!=EOF) {
if (n == ) break;
printf("Case %d: ", cas++);
for (int i = ; i <= n; i++) {
man[i].read();
}
for (int i = ; i <= n; i++) {
scanf("%d",&rk[i]);
} int ans = -;
for (int i = ; i < ; i++) {
if (dfs(man[rk[n]].possible[i], n-)) {
ans = max(ans, man[rk[n]].possible[i]);
} else break;
} if (ans == -) {
puts("No solution");
} else {
printf("%.2f\n", ans/100.0);
}
}
return ;
}

UVALive 3664:Guess(贪心 Grade E)的更多相关文章

  1. UVALive 3835:Highway(贪心 Grade D)

    VJ题目链接 题意:平面上有n个点,在x轴上放一些点,使得平面上所有点都能找到某个x轴上的点,使得他们的距离小于d.求最少放几个点. 思路:以点为中心作半径为d的圆,交x轴为一个线段.问题转换成用最少 ...

  2. UVALive 3507:Keep the Customer Satisfied(贪心 Grade C)

    VJ题目链接 题意: 知道n(n <= 8e6)个工作的完成所需时间q和截止时间d,你一次只能做一个工作.问最多能做多少工作? 思路: 首先很像贪心.观察发现如下两个贪心性质: 1)一定存在一个 ...

  3. UVAlive 2911 Maximum(贪心)

    Let x1, x2,..., xm be real numbers satisfying the following conditions: a) -xi ; b) x1 + x2 +...+ xm ...

  4. uvalive 2911 Maximum(贪心)

    题目连接:2911 - Maximum 题目大意:给出m, p, a, b,然后xi满足题目中的两个公式, 要求求的 xp1 + xp2 +...+ xpm 的最大值. 解题思路:可以将x1 + x2 ...

  5. UVALive - 4225(贪心)

    题目链接:https://vjudge.net/contest/244167#problem/F 题目: Given any integer base b ≥ 2, it is well known ...

  6. UVALive 4850 Installations 贪心

    题目链接  题意 工程师要安装n个服务,其中服务Ji需要si单位的安装时间,截止时间为di.超时会有惩罚值,若实际完成时间为ci,则惩罚值为max{0,ci-di}.从0时刻开始执行任务,问惩罚值最大 ...

  7. UVALive 4863 Balloons 贪心/费用流

    There will be several test cases in the input. Each test case will begin with a line with three inte ...

  8. UVALive - 6268 Cycling 贪心

    UVALive - 6268 Cycling 题意:从一端走到另一端,有T个红绿灯,告诉你红绿灯的持续时间,求最短的到达终点的时间.x 思路:

  9. UVALive 4731 dp+贪心

    这个题首先要利用题目的特性,先贪心,否则无法进行DP 因为求期望的话,越后面的乘的越大,所以为了得到最小值,应该把概率值降序排序,把大的数跟小的系数相乘 然后这种dp的特性就是转移的时候,由 i推到i ...

随机推荐

  1. JZOJ 5347. 遥远的金字塔

    Description Input Output Sample Input 5 3 1 6 1 5 3 5 4 4 4 4 Sample Output 15 Data Constraint 做法: 其 ...

  2. 第48课 thinkphp5添加商品库

    目录 思路: 1. html页面里属性下拉框里的值是从goods_attr联attr里的查出来传到模板里的.在属性的下拉栏里展示出来 2. html页面里用二维数组的结构goods_attr[{$k} ...

  3. Python入门基础--变量与基本数据类型

    变量 什么是变量 变量就是变化的量,变就是变化,量用于衡量描述对象的状态 为什么要有变量 程序执行的本质就是一系列状态的变化,变是程序执行的直接体现,所以我们需要有一种机制能够反映或者说是保存下来程序 ...

  4. HDU:2222-Keywords Search(AC自动机模板,匹配模拟)

    Keywords Search Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others) P ...

  5. input type=file输入框

    <div class="row"> <!--选择图片按钮--> <div class="col-xs-12" align=&quo ...

  6. 笔记-python-build-in-types

    笔记-python-build-in-types 注:文档内容来源为Python 3.6.5 documentation 1.      built-in types 1.1.    真值测试 所有对 ...

  7. unity安装记录

    官网直接下载(http://unity3d.com/cn/) 下载完后,会要求输入账号密码.我是先在官网进行一个账号注册,然后登陆即可. 首先会要你输入一个已有的邮箱,进行认证.进入自己邮箱,点击链接 ...

  8. Wireshark启动出现“无法启动此程序,因为计算机丢失api-ms-win-crt-runtime-l1-1-0.dll。”

    由于重装了win7系统,安装wireshark启动出现了“无法启动此程序,因为计算机丢api-ms-win-crt-runtime-l1-1-0.dll”的问题. 网上查了一圈的资料终解决问题,于是整 ...

  9. dcpromo(server2012不支持)

    dcpromo 编辑 dcpromo命令是一个“开关”命令.如果Windows 2000 Server计算机是成员服务器,则 运行dcpromo命令会安装活动目录,将其升级为域控制器:如果Window ...

  10. 7、JavaScript 知识总结

    1.JavaScript的作用 ①JavaScript 为 HTML 设计师提供了一种编程工具 ②JavaScript 可以将动态的文本放入 HTML 页面 ③JavaScript 可以对事件作出响应 ...