链接:https://www.nowcoder.com/acm/contest/119/F来源:牛客网 Now HUST got a big land whose capacity is C to plant trees. We have n trees which could be plant in it. Each of the trees makes HUST beautiful which determined by the value of the tree. Also each of…
xinjun与阴阳师 题目描述 xinjun是各类手游的狂热粉丝,因随手一氪.一氪上千而威震工大,现在他迷上了阴阳师.xinjun玩手游有一个习惯,就是经过层层计算制定出一套方案来使操作利益最大化(因此即使有扫荡券也不用,故称圣雄肝帝).已知阴阳师有N个模式可以操作,模式i有ai种操作,但每种模式每日只能选用一种操作,可以不选.操作j能收益vj,但需要花费体力wj点.xinjun每日拥有体力M点,求他每日最多能得到多少收益. 输入描述: 第一行一个正整数T(T<=10),表示共有T组数据.对于每…
题目及题目来源 链接:https://www.nowcoder.com/questionTerminal/bfc691e0100441cdb8ec153f32540be2 来源:牛客网 首页 > 试题广场 > max-points-on-a-line [编程题]max-points-on-a-line 热度指数:67696 时间限制:1秒 空间限制:32768K 算法知识视频讲解 Given n points on a 2D plane, find the maximum number of…
Cow Exhibition Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 10949 Accepted: 4344 Description "Fat and docile, big and dumb, they look so stupid, they aren't much fun-" - Cows with Guns by Dana Lyons The cows want to prove to the pu…
01背包和完全背包都是dp入门的经典,我的dp学的十分的水,借此更新博客的机会回顾一下 01背包:给定总容量为maxv的背包,有n件物品,第i件物品的的体积为w[i],价值为v[i],问如何选取才能是背包内的物品价值总和最大. stdin: 5 1 2 3 4 5 5 4 3 2 1 stdout: 14 设dp[i][j]为取前i件物品时容量为j的最优解. 状态转移方程:dp[i][j]=max(dp[i-1][j],dp[i-1][j-w[i]]+v[i]); 压缩后:dp[j]=max(d…
链接: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…
题目我就不贴了...说不定被查到要GG... 题意就是我们需要在P,A,C,M四个属性的限制下,找到符合条件的最优解... 这样我们就需要按照0/1背包的思路,建立一个五维度数组dp[i][j][k][l][o]但是很明显36^5可能不怎么够用,一般来说就两种思路,吧这种多维数组由int 开成 short,这样岂不是爽歪歪?或者降维嘛...这里滚动会降一维,可是不会滚动啊!!!-_-     滚动数组优化!!!我们在正向退DP时,子状态只会用很少的种类,这样前面好多都是没用的,我们来看看简单的0…
题目链接:https://www.nowcoder.com/acm/contest/141/A 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 262144K,其他语言524288K Special Judge, 64bit IO Format: %lld 题目描述 Eddy was a contestant participating in ACM ICPC contests. ACM is short for Algorithm, Coding, Math. Since in…
链接: https://www.nowcoder.com/acm/contest/141/A 题意: 有n(1≤n≤36)个物品,每个物品有四种代价pi,ai,ci,mi,价值为gi(0≤pi,ai,ci,mi,gi≤36),求四种代价分别不超过P,A,C,M(0≤P,A,C,M≤36)的条件下能获得的最大价值,输出所选择的物品. 分析: 01背包的思路,只是代价多了几个而已,数组开多几维就好了.可以用vis[i][p][a][c][m]来表示在四种代价分别为p,a,c,m的状态下是否用第i件物…
gpa 链接:https://www.nowcoder.com/acm/contest/143/A来源:牛客网 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 262144K,其他语言524288K Special Judge, 64bit IO Format: %lld 题目描述 Kanade selected n courses in the university. The academic credit of the i-th course is s[i] and the…