The Preliminary Contest for ICPC Asia Shenyang 2019 C. Dawn-K's water
题目:https://nanti.jisuanke.com/t/41401
思路:完全背包
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,m;
],w[],f[];
while(~scanf("%d%d",&n,&m))
{
memset(f,0x3f,sizeof f);
int res=0x3f3f3f3f;
;
;i<n;i++) scanf("%d%d",&p[i],&w[i]),f[w[i]]=min(f[w[i]],p[i]);
;i<n;i++)
;j++)
{
f[j]=min(f[j],f[j-w[i]]+p[i]);
if(j>=m)
{
if(res>f[j]) res=f[j],maxw=j;
else if(res==f[j]&&j>maxw) maxw=j;
}
}
printf("%d %d\n",res,maxw);
}
;
}
The Preliminary Contest for ICPC Asia Shenyang 2019 C. Dawn-K's water的更多相关文章
- The Preliminary Contest for ICPC Asia Shenyang 2019
传送门 B. Dudu's maze 题意: 是什么鬼东西???我读题可以读半小时QAQ 给出一张无向图,一个人在里面收集糖果,每个点都有一个糖果,特殊点除外.当他第一次进入特殊点时,会随机往一条边走 ...
- The Preliminary Contest for ICPC Asia Shenyang 2019 F. Honk's pool
题目链接:https://nanti.jisuanke.com/t/41406 思路:如果k的天数足够大,那么所有水池一定会趋于两种情况: ① 所有水池都是一样的水位,即平均水位 ② 最高水位的水池和 ...
- The Preliminary Contest for ICPC Asia Shenyang 2019 H. Texas hold'em Poker
题目链接:https://nanti.jisuanke.com/t/41408 题目意思很简单,就是个模拟过程. #include <iostream> #include <cstr ...
- The Preliminary Contest for ICPC Asia Shenyang 2019 H
H. Texas hold'em Poker 思路:根据每个牌型分等级,然后排序按照等级优先,最大值次之,次大值,最后比较剩下值的和. #include<bits/stdc++.h> us ...
- The Preliminary Contest for ICPC Asia Shenyang 2019 C Dawn-K's water (完全背包)
完全背包为什么要取到M,可以取到2*M嘛,这题需要整取,对于不能整取的背包容量,dp[k]=INF,以及dp[j-water[i].weight]=INF时,dp[j]也不需要更新.如果不整取的话,后 ...
- The Preliminary Contest for ICPC Asia Shenyang 2019 D. Fish eating fruit(树形dp)
题意:求一棵树上所有路径和模3分别为0 1 2 的权值的和 思路:树形dp 增加一个记录儿子节点满足条件的个数的数组 不要放在一起dp不然答案跟新会有问题 #include <bits/stdc ...
- The Preliminary Contest for ICPC Asia Shanghai 2019 C Triple(FFT+暴力)
The Preliminary Contest for ICPC Asia Shanghai 2019 C Triple(FFT+暴力) 传送门:https://nanti.jisuanke.com/ ...
- The Preliminary Contest for ICPC Asia Nanjing 2019/2019南京网络赛——题解
(施工中……已更新DF) 比赛传送门:https://www.jisuanke.com/contest/3004 D. Robots(期望dp) 题意 给一个DAG,保证入度为$0$的点只有$1$,出 ...
- 计蒜客 41391.query-二维偏序+树状数组(预处理出来满足情况的gcd) (The Preliminary Contest for ICPC Asia Xuzhou 2019 I.) 2019年徐州网络赛)
query Given a permutation pp of length nn, you are asked to answer mm queries, each query can be rep ...
随机推荐
- 微信小程序页面阻止默认滑动事件
在页面上要加入一个悬浮的按钮,这个按钮需要可以拖动,在元素中使用catchtouchstart,catchtouchmove,catchtouchend来控制悬浮按钮的拖动,但是在ios系统中,微信小 ...
- Leetcode之广度优先搜索(BFS)专题-127. 单词接龙(Word Ladder)
Leetcode之广度优先搜索(BFS)专题-127. 单词接龙(Word Ladder) BFS入门详解:Leetcode之广度优先搜索(BFS)专题-429. N叉树的层序遍历(N-ary Tre ...
- cisco路由的ip路由(一)
路由Corp配置Corp#sh run Building configuration... Current configuration : 1652 bytes ! version 12.4 no s ...
- cisco RIP(传闻协议)Routing information protocol
Corp(config)#rout rip Corp(config-router)#network 10.0.0.0 10.0.0.0/24 is subnetted, 5 subnets C 10. ...
- grep与正则表达式:
1.grep程序 Linux下有文本处理三剑客 -- grep sed awk grep:文本 行过滤工具 sed: 文本 行编辑器(流编辑器) awk:报告生成器(做文本输出格式化) grep ...
- 递归拷贝目录与删除目录 WindowsAPI C++
/*判断一个路径是否是已存在的目录*/ bool IsDirectory(const std::wstring& pstrPath) { DWORD dw = GetFileAttribute ...
- PHP中的接口
对象接口 使用接口(interface),可以指定某个类必须实现哪些方法,但不需要定义这些方法的具体内容. 接口是通过 interface 关键字来定义的,就像定义一个标准的类一样,但其中定义所有的方 ...
- java-selenium上传
一.sendkeys()上传 HTML源码 <td>sendkeys上传</td> <div id='pf'><input type='file' id='p ...
- XPath读取xml文件
1.创建解析工厂 2.创建解析器 3.读xml文件,生成w3c.docment对象树 4.创建XPath对象 5.通过路径查找对象 例子: import javax.xml.parsers.Docum ...
- 矩阵快速幂(Matrix_Fast_Power)
一.基础知识(1)矩阵乘法 https://blog.csdn.net/weixin_43272781/article/details/82899737 简单的说矩阵就是二维数组,数存在里面,矩阵乘法 ...