E. Fire http://codeforces.com/problemset/problem/864/E Polycarp is in really serious trouble — his house is on fire! It's time to save the most valuable items. Polycarp estimated that it would take ti seconds to save i-th item. In addition, for each…
DescriptionCD You have a long drive by car ahead. You have a tape recorder, but unfortunately your best music is on CDs. You need to have it on tapes so the problem to solve is: you have a tape N minutes long. How to choose tracks from CD to get most…
You have a long drive by car ahead. You have a tape recorder, but unfortunately your best music is on CDs. You need to have it on tapes so the problem to solve is: you have a tape N minutes long. How to choose tracks from CD to get most out of tape s…
题目http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=565 分析:题目是一个01背包问题.但是增加了路径输出. 由于路径,所以才有二维递推的形式. dp[i,j]=max{ dp[i-1,j], dp[i-1,j-m[i]]+m[i]} ​在输出集合的时候,如果dp[i,j]==dp[i-1,j],那么表明第i个物品是没有选入的. 采用的逆推…
Happy Programming Contest  ZOJ3703 老实说:题目意思没看懂...(希望路过的大神指点) 最后那个the total penalty time是什么意思啊!!! 还是学到点东西的... 解题的关键在于:要控制最后所用的时间最少,所以在程序的最开始应该先将输入的各种题目 以时间升序排列, 然后就可以保证每次都以时间小的优先选, 这样就可以保证最后相同的吸引值和解题数的情况下所花的时间最少. #include <iostream> #include <stdi…
CD Time Limit:3000MS Memory Limit:0KB 64bit IO Format:%lld & %llu Submit Status Practice UVA 624 Appoint description: Description Download as PDF You have a long drive by car ahead. You have a tape recorder, but unfortunately your best music is on CD…
http://acm.hdu.edu.cn/showproblem.php?pid=6083 题意: 思路: 01背包+路径记录. 题目有点坑,我一开始逆序枚举菜品,然后一直WA,可能这样的话路径记录会有点问题. #include<iostream> #include<algorithm> #include<cstring> #include<cstdio> #include<sstream> #include<vector> #in…
624 - CD 题意:一段n分钟的路程,磁带里有m首歌,每首歌有一个时间,求最多能听多少分钟的歌,并求出是拿几首歌. 思路:如果是求时常,直接用01背包即可,但设计到打印路径这里就用一个二维数组标记一下即可. const int N=1e3+10; int n,m,a[N],d[N],v[N][N]; int main() { while(~scanf("%d%d",&n,&m)) { memset(v,0,sizeof(v)); memset(d,0,sizeof(…
链接:https://www.nowcoder.com/acm/contest/141/A来源:牛客网 Eddy was a contestant participating in ACM ICPC contests. ACM is short for Algorithm, Coding, Math. Since in the ACM contest, the most important knowledge is about algorithm, followed by coding(impl…
题意: 就是找出来一个字典序最小的硬币集合,且这个硬币集合里面所有硬币的值的和等于题目中的M 题解: 01背包加一下记录路径,如果1硬币不止一个,那我们也不采用多重背包的方式,把每一个1硬币当成一个独立的单位来进行01背包dp 但是我们知道背包dp的路径可能不止一条,而我们要从中得到字典序最小的序列,我的代码中两次不同的排序会得到最大/小字典序 降序 == 最小字典序 升序 == 最大字典序 1 #include<iostream> 2 #include<queue> 3 #inc…