题目链接:https://codeforc.es/gym/101933/problem/A

题意:有 n 只青蛙在一个坑里面,要求可以跳出坑的青蛙的最大数量。每个青蛙有 3 种属性:l 为青蛙一次可以跳的高度,w 为青蛙的重量,h 为青蛙作为垫背时的高度,垫背的前提是垫背的青蛙的重量比在他上面的青蛙的总重量要小。

题解:首先将青蛙按重量排序,dp[j]表示在已经垫背的青蛙上面还可以放一个重量  < j 的青蛙时的垫背最大高度,更新的时候,因为重量从大到小排序,dp[j] 由 dp[j + a[i].w] 转移而来,表示把当前的青蛙放到最上面时垫背的最大高度。详见代码~

 #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define mst(a,b) memset((a),(b),sizeof(a))
#define mp(a,b) make_pair(a,b)
#define pi acos(-1)
#define pii pair<int,int>
#define pb push_back
const int INF = 0x3f3f3f3f;
const double eps = 1e-;
const int MAXN = 1e5 + ;
const int MAXM = 1e8 + ;
const ll mod = 1e9 + ; struct node {
int l,w,h;
}a[MAXN]; bool cmp(node x,node y) {
return x.w > y.w;
} int dp[MAXM]; int main() {
#ifdef local
freopen("data.txt", "r", stdin);
// freopen("data.txt", "w", stdout);
#endif
mst(dp, );
int n,d;
scanf("%d%d",&n,&d);
for(int i = ; i < n; i++)
scanf("%d%d%d",&a[i].l,&a[i].w,&a[i].h);
sort(a,a + n,cmp);
int ans = ;
for(int i = ; i < n; i++) {
if(dp[a[i].w] + a[i].l > d) ans++;
int mx = min((int)1e8 - a[i].w, a[i].w);
for(int j = ; j < mx; j++) {
dp[j] = max(dp[j],dp[j + a[i].w] + a[i].h);
if(dp[j] > MAXM) dp[j] = MAXM;
}
}
printf("%d\n",ans);
return ;
}

2018-2019 ACM-ICPC Nordic Collegiate Programming Contest (NCPC 2018) A. Altruistic Amphibians (DP)的更多相关文章

  1. (寒假GYM开黑)2018-2019 ACM-ICPC Nordic Collegiate Programming Contest (NCPC 2018)

    layout: post title: 2018-2019 ACM-ICPC Nordic Collegiate Programming Contest (NCPC 2018) author: &qu ...

  2. 2018-2019 ACM-ICPC Nordic Collegiate Programming Contest (NCPC 2018)- D. Delivery Delays -二分+最短路+枚举

    2018-2019 ACM-ICPC Nordic Collegiate Programming Contest (NCPC 2018)- D. Delivery Delays -二分+最短路+枚举 ...

  3. 2018-2019 ACM-ICPC Nordic Collegiate Programming Contest (NCPC 2018)-E. Explosion Exploit-概率+状压dp

    2018-2019 ACM-ICPC Nordic Collegiate Programming Contest (NCPC 2018)-E. Explosion Exploit-概率+状压dp [P ...

  4. 2019年湖南多校第一场||2018-2019 ACM-ICPC Nordic Collegiate Programming Contest (NCPC 2018)

    第一场多校就打的这么惨,只能说自己太菜了,还需继续努力啊- 题目链接: GYM链接:https://codeforces.com/gym/101933 CSU链接:http://acm.csu.edu ...

  5. 2018-2019 ACM-ICPC Nordic Collegiate Programming Contest (NCPC 2018) - 4.28

    赛后补了几道 赛中我就写了两个... A - Altruistic AmphibiansGym - 101933A 看了眼榜没几个人做.就没看. 最后发现就是一个DP(但是我觉得复杂度有点迷) 题意: ...

  6. Gym .101933 Nordic Collegiate Programming Contest (NCPC 2018) (寒假gym自训第四场)

    (本套题算是比较温和吧,就是罚时有点高. B .Baby Bites 题意:给出一个婴儿给出的数组,有一些数字听不清楚,让你还原,问它是否是一个从1开始的一次增加的数组. 思路:从左往右依次固定,看是 ...

  7. 2018-2019 ACM-ICPC Nordic Collegiate Programming Contest (NCPC 2018) Solution

    A. Altruistic Amphibians Upsolved. 题意: $有n只青蛙,其属性用三元组表示 <l_i, w_i, h_i> l_i是它能跳的高度,w_i是它的体重,h_ ...

  8. [十一集训] Day1 (2018-2019 ACM-ICPC Nordic Collegiate Programming Contest (NCPC 2018))

    A Altruistic Amphibians 原题 题目大意: n只青蛙在高度为d的井中,每只有跳跃距离.重量和高度,每只青蛙可以借助跳到别的青蛙的背上而跳出井,每只青蛙能承受的最大重量是自身重量, ...

  9. 2018-2019 ACM-ICPC Nordic Collegiate Programming Contest (NCPC 2018) D. Delivery Delays (二分+最短路+DP)

    题目链接:https://codeforc.es/gym/101933/problem/D 题意:地图上有 n 个位置和 m 条边,每条边连接 u.v 且有一个距离 w,一共有 k 个询问,每个询问表 ...

随机推荐

  1. [转帖]phoronix-test-suite 简介

    <工作杂记>之phoronix-test-suite 2017年10月30日 14:32:52 打雷下雨 阅读数 2078更多 分类专栏: # linux   版权声明:本文为博主原创文章 ...

  2. 数据库学习其一 oracle11g数据泵导入导出

    一.检查环境一致性 需检查数据库客户端与服务端字符编码,以避免后续各种各样的问题 查询服务端编码 注意最好用sqlplus查询,用plsql有时候会出现查询不一致问题,如下图同一个语句在plsql和s ...

  3. 关于quartz定期,起服务时不新增配置文件中的定期问题

    关于quartz定期,起服务时不新增配置文件中的定期问题 问题原因:生产环境中起服务,未加载配置文件信息,且quartz连接超时 查找原因发现 由于别人新建了一个定期文件 并将 quartz工厂类的i ...

  4. (七)RequestMapping 和 Controller方法

    文章目录 @[toc] RequestMapping功能 controller 方法返回值 RequestMapping功能 url映射 在定义 Controller 的,我们在方法上面,使用 @Re ...

  5. Django学习(2.2.1版本)

    项目技术重难点分析: 模型层:模型是您的数据唯一而且准确的信息来源.它包含您正在储存的数据的重要字段和行为.一般来说,每一个模型都映射一个数据库表. 每各模型都是一个python的类,这些类继承  d ...

  6. spring配置文件和spring mvc配置文件的区别

    Question: Are applicationContext.xml and spring-servlet.xml related anyhow in Spring Framework? Will ...

  7. 有趣的后渗透工具 Koadic

    koadic是DEFCON黑客大会上分享出来的的一个后渗透工具,虽然和msf有些相似,但是Koadic主要是通过使用Windows ScriptHost(也称为JScript / VBScript)进 ...

  8. Iedis - Redis 在IDEA中的可视化工具破解

    2.如何破解 // 如果你没有改动IDEA的话,IDEA的插件库在这个目录下C:\Users\Administrator\.IntelliJIdea2017.3\config\plugins\Iedi ...

  9. winfrom_动态添加按钮button(设置颜色,大小,按钮字体大小、颜色,位置,事件)

    List<string> strColor = new List<string>(); strColor.Add("#e67817"); strColor. ...

  10. 在Android8.0以上收不到广播问题(AppWidget)

    对Intent指定组件 //安卓8.0必须添加 intent.setComponent(new ComponentName(context,MyAppWidgetProvider.class)); 问 ...