vj题目链接

题意:

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

思路:

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

坑点:

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

代码:

  1. #include <cstdio>
  2. #include <cstring>
  3. #include <algorithm>
  4. using namespace std;
  5.  
  6. #define N 20000
  7.  
  8. struct Man{
  9. int a[];
  10. int possible[];
  11. void read() {
  12. for (int i = ; i < ; i++) {
  13. double tmp;
  14. scanf("%lf", &tmp);
  15. a[i] = (int)((tmp+1e-)*);
  16. }
  17. for (int i = ; i < ; i++) {
  18. int sum = ;
  19. for (int j = ; j < ; j++) {
  20. if ((i>>j)&) {
  21. sum += a[j];
  22. }
  23. }
  24. possible[i] = sum;
  25. }
  26. sort(possible, possible+);
  27. }
  28. }man[N];
  29. int rk[N];
  30. int n;
  31.  
  32. bool dfs(int pre, int id) {
  33. if (id <= ) return true;
  34. int minres = 0x3f3f3f3f;
  35. bool isok = false;
  36. for (int i = ; i >= ; i--) {
  37. if (man[rk[id]].possible[i] > pre || (man[rk[id]].possible[i] == pre && rk[id] < rk[id+])) {
  38. isok = true;
  39. minres = min(minres, man[rk[id]].possible[i]);
  40. } else break;
  41. }
  42. if (!isok) return false;
  43.  
  44. return dfs(minres, id-);
  45. }
  46.  
  47. int main() {
  48. int cas = ;
  49. while (scanf("%d", &n)!=EOF) {
  50. if (n == ) break;
  51. printf("Case %d: ", cas++);
  52. for (int i = ; i <= n; i++) {
  53. man[i].read();
  54. }
  55. for (int i = ; i <= n; i++) {
  56. scanf("%d",&rk[i]);
  57. }
  58.  
  59. int ans = -;
  60. for (int i = ; i < ; i++) {
  61. if (dfs(man[rk[n]].possible[i], n-)) {
  62. ans = max(ans, man[rk[n]].possible[i]);
  63. } else break;
  64. }
  65.  
  66. if (ans == -) {
  67. puts("No solution");
  68. } else {
  69. printf("%.2f\n", ans/100.0);
  70. }
  71. }
  72. return ;
  73. }

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. url传参及重定向

    成功跳转$this -> success('提示语',跳转路径,返回的数据,时间,发送的 Header 信息)跳转失败$this -> error('提示语',跳转路径,返回的数据,时间, ...

  2. 数据结构-二叉树(Binary Tree)

    #include <stdio.h> #include <string.h> #include <stdlib.h> #define LIST_INIT_SIZE ...

  3. A Bug's Life(削弱版食物链)

    Description Background  Professor Hopper is researching the sexual behavior of a rare species of bug ...

  4. Flask学习笔记:数据库迁移操作flask-script+alembic/flask-migrate

    数据库迁移是将代码中模型类(即表)的修改同步到数据库中, flask-sqlalchemy的模型类一旦使用create_all()映射到数据库中后,对这个模型类的修改(例如添加了一个新的字段)就不会再 ...

  5. ubuntu 把软件源修改为国内源和更新(转载)

    1. 备份原始文件 sudo cp /etc/apt/sources.list /etc/apt/sources.list.backup 2. 修改文件并添加国内源 vi /etc/apt/sourc ...

  6. Harbor HA部署-使用Ceph RADOS后端

    1. 前言 Harbor 1.4.0版本开始提供了HA部署方式,和非HA的主要区别就是把有状态的服务分离出来,使用外部集群,而不是运行在本地的容器上.而无状态的服务则可以部署在多个节点上,通过配置上层 ...

  7. 1001: [BeiJing2006]狼抓兔子(对偶图)

    1001: [BeiJing2006]狼抓兔子 Time Limit: 15 Sec  Memory Limit: 162 MBSubmit: 23595  Solved: 5940 Descript ...

  8. “帮你APP”团队冲刺4

    1.整个项目预期的任务量 (任务量 = 所有工作的预期时间)和 目前已经花的时间 (所有记录的 ‘已经花费的时间’),还剩余的时间(所有工作的 ‘剩余时间’) : 所有工作的预期时间:88h 目前已经 ...

  9. java基础_单例模式

    java开发实战经典 --单例模式 从CSDN以及博客园的相关文章学习的,摘做笔记. “java中单例模式是一种常见的设计模式,单例模式的写法有好几种,这里主要介绍三种:懒汉式单例.饿汉式单例.登记式 ...

  10. hnust Snowman

    问题 D: Snowman 时间限制: 1 Sec  内存限制: 128 MB提交: 203  解决: 94[提交][状态][讨论版] 题目描述 前言:这是某比赛的热身题,本题主要考察英文水平,只要看 ...