Atcoder Beginner Contest153E(完全背包)
完全背包,价值取题意代价的最小值
#define HAVE_STRUCT_TIMESPEC
#include<bits/stdc++.h>
using namespace std;
int a[],b[],f[];
int main(){
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int h,n;
cin>>h>>n;
for(int i=;i<=n;++i)
cin>>a[i]>>b[i];
for(int i=;i<=h;++i)
f[i]=1e9;
f[]=;
for(int i=;i<=n;++i)
for(int j=;j<=h;++j){
int x=max(,j-a[i]);
f[j]=min(f[j],f[x]+b[i]);
}
cout<<f[h];
return ;
}
Atcoder Beginner Contest153E(完全背包)的更多相关文章
- AtCoder Beginner Contest 153 题解
目录 AtCoder Beginner Contest 153 题解 A - Serval vs Monster 题意 做法 程序 B - Common Raccoon vs Monster 题意 做 ...
- AtCoder Beginner Contest 100 2018/06/16
A - Happy Birthday! Time limit : 2sec / Memory limit : 1000MB Score: 100 points Problem Statement E8 ...
- AtCoder Beginner Contest 052
没看到Beginner,然后就做啊做,发现A,B太简单了...然后想想做完算了..没想到C卡了一下,然后还是做出来了.D的话瞎想了一下,然后感觉也没问题.假装all kill.2333 AtCoder ...
- AtCoder Beginner Contest 053 ABCD题
A - ABC/ARC Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem Statement Smeke has ...
- AtCoder Beginner Contest 136
AtCoder Beginner Contest 136 题目链接 A - +-x 直接取\(max\)即可. Code #include <bits/stdc++.h> using na ...
- AtCoder Beginner Contest 137 F
AtCoder Beginner Contest 137 F 数论鬼题(虽然不算特别数论) 希望你在浏览这篇题解前已经知道了费马小定理 利用用费马小定理构造函数\(g(x)=(x-i)^{P-1}\) ...
- AtCoder Beginner Contest 076
A - Rating Goal Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem Statement Takaha ...
- AtCoder Beginner Contest 079 D - Wall【Warshall Floyd algorithm】
AtCoder Beginner Contest 079 D - Wall Warshall Floyd 最短路....先枚举 k #include<iostream> #include& ...
- AtCoder Beginner Contest 064 D - Insertion
AtCoder Beginner Contest 064 D - Insertion Problem Statement You are given a string S of length N co ...
随机推荐
- 解决Maven依赖报红的批处理文件
maven经常因为网络或者其他原因导致仓库jar包下载不完整,导致jar包依赖报红,此小工具可以一键删除未下载完成文件 set REPOSITORY_PATH=E:\deplor\apache-mav ...
- 剪切文件或目录命令 - mv
①.命令名称:mv ②.英文原意:move ③.命令所在路径:/bin/mv ④.执行权限:所有用户 ⑤.功能描述:剪切文件.改名 ⑥.语法: mv[原文件或目录][目标目录] 例子:在 tmp目录下 ...
- ISCC2018_leftleftrightright-Writeup
leftleftrightright(150) 这个题学到了不少东西,值得认真写一下 下载好文件后发现是upx的壳,upx -d直接脱掉后运行,发现是经典的check输入的题目(作为一个linuxer ...
- 字符串UTF-8和GBK之间的转换以及判定
一.判定字符串是否是UTF-8的编码 bool is_str_utf8(const char* str) { unsigned ;//UFT8可用1-6个字节编码,ASCII用一个字节 unsigne ...
- 在github网站上更新fork的repo
打开fork的repo. 点击Pull request, 这里会跳转到一个页面提示There isn’t anything to compare. 点击switching the base,将orig ...
- 关于Win32串口
因为近段时间接触Hid相对来说多一些,由此忽略了串口中获取cbInQue这个重要的东西,下面是错误代码 // Win32SerialPortLib.cpp : 定义 DLL 应用程序的导出函数. // ...
- IntelliJ IDEA 2017.3尚硅谷-----配置 Tomcat
- Entity Framework 简介
Entity Framework Entity Framework 的全称为 ADO.NET Entity Framework,简称 EF. 1.与 ADO.NET 的关系 Entity F ...
- 生产环境实践:Cana实现MySQL到ES实时同步
注:由于文章篇幅有限,完整文档可扫下面二维码免费获取,更有深受好评的大数据实战精英+架构师好课等着你. 速点链接加入高手战队:http://www.dajiangtai.com/course/112. ...
- 密码学笔记——zip明文攻击
明文攻击(Known plaintext attack):是一种攻击模式,指攻击者已知明文.密文及算法,求密钥的过程. 例题: 这就是一个坑 密码是十位大小写字母.数字.特殊符号组成的,你爆破的开么? ...