ZOJ 3956 Course Selection System (dp 01背包)
来源:互联网 发布:淘宝swot分析 编辑:程序博客网 时间:2024/05/16 19:53
思路
题目要求
代码
#include <bits/stdc++.h>#define mem(a,b) memset(a,b,sizeof(a))#define rep(i,a,b) for(int i=a;i<b;i++)const int INF=0x3f3f3f3f;const int maxn=1e3+50;const int mod=9901;#define pii pair<int,int>typedef long long ll;typedef unsigned int ui;using namespace std;int w[maxn],c[maxn];int dp[50050];int main(){#ifndef ONLINE_JUDGE //freopen("in.txt","r",stdin); //freopen("out.txt","w",stdout);#endif int T,n; scanf("%d",&T); while(T--){ scanf("%d",&n); rep(i,0,n) scanf("%d %d",&w[i],&c[i]); mem(dp,0); rep(i,0,n) for(int j=50000;j>=c[i];j--){ dp[j]=max(dp[j],dp[j-c[i]]+w[i]); } ll ans=0; rep(i,0,50001){ ll totH=dp[i]; ans=max(ans,totH*totH-totH*i-(ll)i*i); } printf("%lld\n",ans); } return 0;}
0 0
- 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背包)
- zoj 3956-Course Selection System(背包)
- ZOJ 3956 Course Selection System (dp)
- ZOJ 3956 Course Selection System(01背包)
- Zoj 3956 Course Selection System (01背包)
- zoj 3596Course Selection System(dp,01背包)
- 浙大17年校赛(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
- ZOJ 3956 Course Selection System
- Spark:超越Hadoop MapReduce
- 山地车碟刹有响声怎么解决?
- MD5加盐
- 编程实现一个单链表实现创建、测长以及打印
- 异常类型
- ZOJ 3956 Course Selection System (dp 01背包)
- clreol函数
- Ecshop模板开发(二十二):商品浏览记录显示
- sdut_java_下沉的船
- 空间配置器
- Java关于接口引用实现该接口类的对象
- Publishing Settings (keystore password) 保存密码
- 王道机试第三章总结
- jq 实现 验证码倒计时(前端部分)