P2392 kkksc03考前临时抱佛脚 题解 01背包,类似于这道题,相似度99.999999%: 01-背包 P2663 越越的组队   一共有4科,每科的时间独立,然后每一科做一遍 P2663越越的组队,时间之和累加得到答案   考虑复习每一科的最短时间 由于可以左右脑并用,所以把题目简化一下就是把所有题目分成两组,取时间最长的一组作为答案,但是要使得时间最长的一组它的时间尽量短 我们知道两组数值越接近,肯定就是最优答案了   代码 #include<iostream> #include…
P2392 kkksc03考前临时抱佛脚 题目背景 kkksc03的大学生活非常的颓废,平时根本不学习.但是,临近期末考试,他必须要开始抱佛脚,以求不挂科. 题目描述 这次期末考试,kkksc03需要考4科.因此要开始刷习题集,每科都有一个习题集,分别有s1,s2,s3,s4道题目,完成每道题目需要一些时间,可能不等(A1...As1,B1...Bs2,C1...Cs3,D1...Ds4). kkksc03有一个能力,他的左右两个大脑可以同时计算2道不同的题目,但是仅限于同一科.因此,kkksc…
题目链接 P2392 kkksc03考前临时抱佛脚 - 洛谷 | 计算机科学教育新生态 (luogu.com.cn) 题目 dp代码 #include <iostream> #include <cmath> #include <cstring> using namespace std; int a[4][25], dp[2000]; int s[4]; int sum[4]; int main() { cin >> s[0] >> s[1] &g…
题意:过山车有n个区域,一个人有两个值F,D,在每个区域有两种选择: 1.睁眼: F += f[i], D += d[i] 2.闭眼: F = F ,     D -= K 问在D小于等于一定限度的时候最大的F. 解法: 用DP来做,如果定义dp[i][j]为前 i 个,D值为j的情况下最大的F的话,由于D值可能会增加到很大,所以是存不下的,又因为F每次最多增加20,那么1000次最多增加20000,所以开dp[1000][20000],dp[i][j]表示前 i 个,F值为j的情况下最小的D.…
Team Them Up! Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 7608   Accepted: 2041   Special Judge Description Your task is to divide a number of persons into two teams, in such a way, that: everyone belongs to one of the teams; every t…
传送门 Description Hasan and Bahosain want to buy a new video game, they want to share the expenses. Hasan has a set of N coins and Bahosain has a set of M coins. The video game costs W JDs. Find the number of ways in which they can pay exactly W JDs su…
题目链接: http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1085 题意: 中文题诶~ 思路: 01背包模板题. 用dp[i][j]表示到第i个物品花去j空间能存储的最大价值, 那么很显然有 ; i<=n; i++){ ; j<=m; j++){ //注意这里的j是从0开始而非a[i] if(j>=a[i]){ dp[i][j]=max(dp[i-][j-a[i]]+b[i], dp[i-][j]); }els…
In Action Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 5472    Accepted Submission(s): 1843 Problem Description Since 1945, when the first nuclear bomb was exploded by the Manhattan Project t…
题意:给你若干个集合,每个集合内的物品要么选任意一个,要么所有都选,求最后在背包能容纳的范围下最大的价值. 分析:对于每个并查集,从上到下滚动维护即可,其实就是一个01背包= =. 代码如下: #include <stdio.h> #include <algorithm> #include <string.h> #include <vector> using namespace std; + ; int w[N],b[N]; int n,m,W; int r…
Charm Bracelet Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 34532   Accepted: 15301 Description Bessie has gone to the mall's jewelry store and spies a charm bracelet. Of course, she'd like to fill it with the best charms possible fro…