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 5461. 【NOIP2017提高A组冲刺11.8】购物

    5461. [NOIP2017提高A组冲刺11.8]购物 (File IO): input:shopping.in output:shopping.out Time Limits: 1000 ms   ...

  2. 关于在namanode上编写脚本控制DataNode的...

    脚本如下:(我的虚拟机名字分别为:wang201 wang 202 wang 203 wang 204) params=$@ i= ; i <= ; i++)) ; do echo ====== ...

  3. Python9-前端基础知识-day47

    web开发本质: 1.浏览器输入网址回车都发生了什么? 1.浏览器给服务端发送一个消息 2.服务端拿到消息 3.服务端返回消息 4.浏览器展示页面C/S架构----B/S架构客户端和服务端 消息的格式 ...

  4. Centos7(Linux)下安装VMware12

    https://blog.csdn.net/u012605477/article/details/65627234

  5. 802. Find Eventual Safe States

    https://leetcode.com/problems/find-eventual-safe-states/description/ class Solution { public: vector ...

  6. Java最小堆解决TopK问题

    TopK问题是指从大量数据(源数据)中获取最大(或最小)的K个数据. TopK问题是个很常见的问题:例如学校要从全校学生中找到成绩最高的500名学生,再例如某搜索引擎要统计每天的100条搜索次数最多的 ...

  7. D3DXCreateTexture

    HRESULT D3DXCreateTexture( __in LPDIRECT3DDEVICE9 pDevice, __in UINT Width, __in UINT Height, __in U ...

  8. 63、加速android应用(转载)

    本文转自 http://www.devtf.cn/?p=1097 原文链接 : Speed up your app原文作者 : UDI COHEN译文出自 : 开发技术前线 www.devtf.cn. ...

  9. centos开机启动项设置命令:chkconfig

    在CentOS或者RedHat其他系统下,如果是后面安装的服务,如httpd.mysqld.postfix等,安装后系统默认不会自动启动的.就算手动执行/etc/init.d/mysqld start ...

  10. java如何建项目

    java常开发的项目有哪几种? 这几种项目都是怎么建的?