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 ...
随机推荐
- C++ socket编程-转载
转自:https://www.cnblogs.com/L-hq815/archive/2012/07/09/2583043.html 若有违规请联系我删除. 介绍 Socket编程让你沮丧吗?从man ...
- 【转】Java Future 怎么用 才算是真正异步
接着上一篇继续并发包的学习,本篇说明的是Callable和Future,它俩很有意思的,一个产生结果,一个拿到结果. Callable接口类似于Runnable,从名字就可以看出来了,但 ...
- NOI2005 维护数列 lg2042
这道题据说是noi题目中算是比较毒瘤的数据结构题了,5k多的代码加上随手写挂细节,我调了两天 题面见https://www.luogu.org/problemnew/show/P2042 (歪个题,这 ...
- [POI2005]KOS-Dicing (最大流+二分)lg3425
题面https://www.luogu.org/problemnew/show/P3425 题面说赢的最多的人最少赢几场,肯定是向二分的方向思考 建立源点向每一场比赛连容量为1的边,从每场比赛向参赛两 ...
- python爬取连续一字板股票及当时日期数据【原创分享】
本篇为个人测试记录,记录爬取连续一字板的股票及当时日期. import tushare as ts import pandas as pd import time # 筛选一字板的策略 def gp_ ...
- python笔记-01
Python环境安装 1.Windows下一键环境安装包 2.Python2.X与Python3.X 什么是代码? 代码是现实世界事物在计算机世界中的映射 什么是写代码? 写代码是将现实世界中的事物用 ...
- javascript闭包的理解和实例
所谓闭包,值得是词法表示包括不必要计算的变量的函数,也就是说,该函数可以使用函数外定义的变量. 顺便提示一下: 词法作用域:变量的作用域是在定义时决定而不是执行时决定,也就是说词法作用域取决于源码,通 ...
- @Cacheable注解不生效原因
因为@Cacheable注解应用了AOP动态代理,生成代理类,判断缓存中是否存在该key,如果不存在则调用被代理类的标有@Cachable注解的方法,否则不执行. 所以当类A的方法a调用方法b(标有@ ...
- 一些docker资料汇总
安装vmtools https://blog.csdn.net/qq_37764098/article/details/95538813 挂载vm共享文件夹 https://www.cnblogs.c ...
- pve proxmox 常见问题,perl warning
pve命令,如下报错 perl: warning: Setting locale failed. perl: warning: Please check that your locale settin ...