Digging Time Limit: 2000ms Memory Limit: 65536KB This problem will be judged on ZJU. Original ID: 368964-bit integer IO format: %lld      Java class name: Main Prev Submit Status Statistics Discuss Next Type: None   None Graph Theory 2-SAT Articulati…
物品分堆 Time Limit: 2000/1000ms (Java/Others) Problem Description: 有n个物品,物品i的重量为Wi,现在想要把这个n个物品分类两堆,求最小的重量差(物品不可分割). Input: 输入包含多组测试,每组测试第一行输入一个整数n(1≤n≤100);第二行输入n个整数Wi(1≤ai≤10^4). Output: 对于每组测试,输出一个数字,表示分成两堆后的最小质量差. Sample Input: 5 2 3 5 23 35 5 10 7 8…
Description When it comes to the Maya Civilization, we can quickly remind of a term called the end of the world. It's not difficult to understand why we choose to believe the prophecy (or we just assume it is true to entertain ourselves) if you know…
Digging Time Limit: 2 Seconds      Memory Limit: 65536 KB When it comes to the Maya Civilization, we can quickly remind of a term called the end of the world. It's not difficult to understand why we choose to believe the prophecy (or we just assume i…
Course Selection System ZOJ - 3956 这个题目居然是一个01背包,我觉得好难想啊,根本就没有想到. 这个题目把题目给的转化为  ans = a*a-a*b-b*b 这个可以看成 当b不变的时候 a 越大越好. 这个就可以用01背包来解决 #include <cstdio> #include <cstring> #include <algorithm> #include <iostream> #include <algor…
题目链接:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=565 题意很好理解,普通的01背包,dp[i - 1][j]表示在前i - 1件物品中选取若干物品放入容量为j背包所得到的最大的价值,dp[i - 1][j - w[i]] + v[i]表示前i - 1件物品中选取若干物品放入容量为j - w[i]背包所得到的最大的价值加上第i件物…
D - Digging Time Limit:2000MS     Memory Limit:65536KB     64bit IO Format:%lld & %llu Submit Status Description When it comes to the Maya Civilization, we can quickly remind of a term called the end of the world. It's not difficult to understand why…
裸的01背包.dp[x]只要是bool型记录当前空间是否可用.. 而为了找到用了哪些物品..dp[x]设置为int型..进行记录.. Program: #include<iostream> #include<stdio.h> #include<string.h> #include<algorithm> #include<cmath> #define oo 1000000007 #define ll long long #define pi aco…
题意:买东西,每个东西有三个特征值,p代表价格,q代表你手中钱必须不低于q才能买这个物品,v代表得到的价值. mark:又是变种01背包,每做一个变种的,就是一种提高.. 按照q - p以由大到小的顺序排序,然后进行01背包的DP即可. #include<stdio.h> #include<algorithm> #include<iostream> using namespace std; const int MAXN=5005; int dp[MAXN]; struc…
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3956 题意:就是给你Hi,Ci的值,问怎么取使得下面那个式子的值最大: 理解:当时做了好久以为是贪心>_<.后来看别人的题解发现是01背包,现在学了01背包以后看就好理解多了. 因为每个值都是取或不取,所以容易想到是01背包.而且Hi的范围是[1,10000],Ci的范围是[1,100],n是[1,500],所以明显可以发现Ci适合做“物品体积”,Hi做“物品价值”,Σ…