zoj 3596Course Selection System(dp,01背包)
来源:互联网 发布:jquery数组push 编辑:程序博客网 时间:2024/06/05 10:26
题目描述
给你
分析
设
AC code
#include <cstdio>#include <iostream>#include <vector>#include <queue>#include <algorithm>#include <cmath>#include <cstring>#include <map>#include <set>#include <iomanip>#include <bitset>#define pb push_back#define mp make_pair#define PI acos(-1)#define fi first#define se second#define INF 0x3f3f3f3f#define INF64 0x3f3f3f3f3f3f3f3fusing namespace std;const int MOD = 1e9+7;const int MAX_P = 2e4+10;const int maxn = 50000+10;const int MAX_V = 5e5+10;typedef long long LL;typedef long double DB;typedef pair<int,int> Pair;LL dp[maxn];Pair a[maxn];int main() { int T; scanf("%d",&T ); while (T--) { int n; scanf("%d",&n ); int maxv = 0; for(int i=0 ; i<n ; ++i){ scanf("%d%d",&a[i].fi,&a[i].se); maxv += a[i].se; } memset(dp,0,sizeof(dp)); for(int i=0 ; i<n ; ++i){ for(int j = maxv ; j-a[i].se >=0 ;--j){ dp[j] = max(dp[j],dp[j-a[i].se]+a[i].fi); } } LL ans=0; for(int i=0 ; i<=maxv ; ++i){ ans = max(ans,dp[i]*dp[i]-(dp[i]+i)*i); } std::cout << ans << '\n'; } return 0;}
0 0
- zoj 3596Course Selection System(dp,01背包)
- ZOJ 3956 Course Selection System (dp 01背包)
- ZOJ 3956 Course Selection System 01背包
- Zoj 3956 Course Selection System【01背包】
- ZOJ 3956 Course Selection System 01背包
- ZOJ-3956 Course Selection System,01背包!
- ZOJ-3956 Course Selection System(01背包)
- 浙大17年校赛(ZOJ 3956)Course Selection System[01背包]
- ZOJ 3956 Course Selection System(01背包)
- Zoj 3956 Course Selection System (01背包)
- ZOJ 3956 Course Selection System 01背包变形
- 浙大校赛 ZOJ 3956Course Selection System (01背包)
- ZOJ 3956 Course Selection System(01背包变形)
- ZOJ 3956 Course Selection System 【 思维 + 01背包 】
- zoj 3956-Course Selection System(背包)
- Course Selection System 01背包
- ZOJ 3956 Course Selection System (dp)
- Course Selection System ZOJ
- linux下的命令
- Python学习9-面向对象编程
- Andriod 自定义控件之音频条
- Problem C: 点在圆内吗?
- 【tyvj1313】烽火传递(单调队列优化dp)
- zoj 3596Course Selection System(dp,01背包)
- OCS:史上最疯狂的iOS动态化方案
- 为Hexo-Next主题设置头部图片
- MD5二次加密的小例子
- String字符串逆序输出的两种方式
- nginx压缩、缓存、限速
- HTML5之SVG 2D入门7
- Source Insight基本使用和快捷键
- react-native run-android 提示 java.lang.UnsupportedClassVersionError: com/android/build/gradle/AppPlug