文章目录

  • 题目描述
  • 输入描述:
  • 输出描述:
  • 示例1

题目描述

Recently, a job for an algorithms specialist opened up at NIH. You never thought you’d be using your expertise in algorithms to save lives, but now, here is your chance! While the doctors are very good in carrying out medical research and coming up with better cures for diseases, they are not so good with numbers. This is where you come in.

You have been tasked to allocate money for all disease research at NIH. The interesting thing about disease research is that the number of lives saved doesn’t linearly increase with the amount of money spent, in most cases. Instead, there are “break-points”. For example, it might be the case that for disease A, we have the following break-points:

Research Funding

Lives Saved

10 million

5

50 million

100

100 million

1000

250 million

1100

If you spend more money than one breakpoint and less than another, the number of lives saved is equal to the amount saved for the previous breakpoint. (In the above example, if you spent 150 million, you’d still only save 1000 lives, and if you spent any amount more than 150million,you’dstillonlysave1000lives,andifyouspentanyamountmorethan250 million, you’d still save 1100 lives.)

The doctors have figured out charts just like this one for all the diseases for which they do research. Given these charts, your job will be to maximize the number of lives saved spending no more than a particular budget.

The Problem:

Given several charts with information about how much has to be spent to save a certain number of lives for several diseases and a maximum amount of money you can spend, determine the maximum number of lives that can be saved.

输入描述:

The first input line contains a positive integer, n (n ≤ 100), indicating the number of budgets to consider. The first line of each budget contains two positive integers, d (d ≤ 10), representing the number of diseases for which there is data and B (B ≤ 100000), the total budget, in millions of dollars. The following d lines contain information about each of the d diseases. Each of these lines will contain exactly four ordered pairs of positive integers separated by spaces. Each pair will represent a dollar level (in millions) followed by the number of lives saved for that dollar

level of funding. Each of the pairs will be separated by spaces as well. Each of these values will be less than or equal to 100,000. Assume that the dollar levels on an input line are distinct and in increasing order, and that the number of lives saved on an input line are also distinct and in increasing order.

输出描述:

For each test case, just output a line with the following format:
Budget #k: Maximum of x lives saved.
where k is the number of the budget, starting at 1, and x is the maximum number of lives saved in that budget.
Leave a blank line after the output for each test case.

示例1

输入
3
2 2000
10 5 50 100 100 1000 250 1100
100 1 200 2 300 3 1900 1000
3 100
10 100 40 200 70 300 100 500
5 1 25 2 35 3 50 4
200 10000 300 20000 400 30000 500 40000
1 10
100 2 200 3 300 5 400 6

输出
Budget #1: Maximum of 2000 lives saved.

Budget #2: Maximum of 500 lives saved.

Budget #3: Maximum of 0 lives saved.

#include<bits/stdc++.h>
using namespace std;
const int maxn=1e6+10;
int dp[maxn],a[maxn],b[maxn];
int mp[maxn];
int main(){int t;int x,y;cin>>t;  int k=0;while(t--){memset(dp,0,sizeof(dp));cin>>x>>y;for(int i=1;i<=x;i++){for(int k=0;k<4;k++)cin>>a[k]>>b[k];for(int j=y;j>=0;j--)for(int k=0;k<4;k++){if(j>=a[k])dp[j]=max(dp[j],dp[j-a[k]]+b[k]);}}k++;printf("Budget #%d: Maximum of %d lives saved.\n\n",k,dp[y]);}return 0;
}

牛客 2021年度训练联盟热身训练赛第二场 E题NIH Budget相关推荐

  1. 2021年度训练联盟热身训练赛第三场赛后补题

    2021年度训练联盟热身训练赛第三场赛后补题 A Circuit Math [题目分析] [代码展示] B Diagonal Cut [题目分析] [代码展示] C Gerrymandering [题 ...

  2. 2021年度训练联盟热身训练赛第三场(待补)

    文章目录 前言 一.Circuit Math(后缀表达式---栈&&fgets) 二.Diagonal Cut(gcd最大公因数,数论) 三.expected primary-expr ...

  3. 2021年度训练联盟热身训练赛第四场 H - Rock Paper Scissors(字符串匹配,FFT)

    整理的算法模板合集: ACM模板 点我看算法全家桶系列!!! 实际上是一个全新的精炼模板整合计划 2021年度训练联盟热身训练赛第四场 H - Rock Paper Scissors(字符串匹配,FF ...

  4. 2021年度训练联盟热身训练赛第五场

    2021年度训练联盟热身训练赛第五场 链接:https://ac.nowcoder.com/acm/contest/13926 A Binary Seating #include<bits/st ...

  5. 2021年度训练联盟热身训练赛第八场

    目录 2021年度训练联盟热身训练赛第八场 A-Fire on Field 题意 思路 代码 B-Gene Tree 题意 思路 代码 I-Thread Knots 题意 思路 代码 J-Triang ...

  6. 2021年度训练联盟热身训练赛第五场F题Group Project

    题意: 有n个人,其中有m组,两两互斥,现在要分成两个班,但最终求的确是最多有多少对不互斥的. 题目: 链接:https://ac.nowcoder.com/acm/contest/16741/F 来 ...

  7. 2021年度训练联盟热身训练赛第五场 H题In-place Sorting+贪心构造

    题意: 给你n个小于101810^{18}1018的大数,问在可以再不改变序列位置,之改变数值中某数位的'9'变为'6'或将'6'变为'9',求的最终序列由小到大,且字典序最小. 题目: 链接:htt ...

  8. 2021年度训练联盟热身训练赛第四场,签到题CDF

    概述 题号 标题 已通过代码 通过率 团队的状态 A Broadcast Stations 点击查看 17/55 未通过 B Connect3 点击查看 167/234 未通过 C Game Map ...

  9. 2021年度训练联盟热身训练赛第二场(ICPC North Central NA Contest 2019,南阳师范学院),签到题ABCDEFGIJ

    A. Binarize It,简单枚举 链接:https://ac.nowcoder.com/acm/contest/12794/A 来源:牛客网 题目描述 Professor Boolando ca ...

最新文章

  1. 教你用OpenCV实现机器学习最简单的k-NN算法
  2. 违反计算机网络安全如何处罚,网络信息安全知识:违反治安管理行为的处罚包括()。...
  3. 聂聪:数据科学让我为城市规划注入创新价值 | 优秀毕业生专访
  4. mysql指令按顺序排列_mysql基本语法大全
  5. jquery 图像滑块_jQuery CSS图像滑块–自行编写代码
  6. SparkSql与Redis综合练习
  7. 拓端tecdat|如何用R语言绘制生成正态分布图表
  8. 程序员如何写简历|附10个模版
  9. 【WiFi】WiFi 5G信道和频宽的对应关系
  10. LeetCode初级算法之数组:有效数独
  11. python绘制多个散点图_绘制多个散点图熊猫
  12. 我对M4A文件格式的理解
  13. 数组、字符串长度的计算
  14. EOS智能合约开发(三)EOS创建和管理账户
  15. java什么是线程安全_什么是线程安全?
  16. 第二十四章 Caché 变量大全 $ZA 变量
  17. Android 报错A/libc: Fatal signal 6 (SIGABRT), code -6 in tid *** 解决
  18. 新手做网站只需要4个步骤
  19. 安卓数据转移到iphone老是中断_关于iPhone手机之间数据转移的几种方式
  20. 《The One !团队》:BETA Scrum metting2

热门文章

  1. 结对项目-使用计算器的设计和介绍
  2. 推荐LaTeX在线编辑器
  3. 简单实现 C# TabControl 不显示选项卡标题
  4. 报表FineReport部署Tomcat服务器
  5. 帆软报表判断传入条件是否为空,根据逗号分隔
  6. Java中四种遍历Map对象的方法
  7. Java基础 main 参数String[] args的用法
  8. [UE4]函数和事件的区别
  9. 九尾之火---算法生成的动画图像
  10. Windows API 学习记录1