bzoj 4247挂饰
背包????不会。。。
#include<bits/stdc++.h>
#define INF 0x7fffffff
#define LL long long
#define N 100005
using namespace std;
inline int ra()
{
int x=,f=; char ch=getchar();
while (ch<'' || ch>'') {if (ch=='-') f=-; ch=getchar();}
while (ch>='' && ch<='') {x=x*+ch-''; ch=getchar();}
return x*f;
}
struct node{int a,b;}a[N];
LL f[][];
bool cmp(node a, node b){return a.a>b.a;}
int main()
{
int n=ra();
for (int i=; i<=n; i++) a[i].a=ra(),a[i].b=ra();
sort(a+,a+n+,cmp);
for (int i=; i<=n; i++) for (int j=; j<=n+; j++) f[i][j]=-0x3f3f3f3f; f[][]=;
for (int i=; i<=n; i++)
for (int j=; j<=n; j++)
f[i][j]=max(f[i-][j],f[i-][max(j-a[i].a,)+]+a[i].b);
LL ans=-0x3f3f3f3f;
for (int i=; i<=n; i++)
ans=max(ans,f[n][i]);
cout<<ans;
return ;
}
bzoj 4247挂饰的更多相关文章
- BZOJ 4247 挂饰 背包DP
4247: 挂饰 Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://www.lydsy.com/JudgeOnline/problem.php?id ...
- BZOJ 4247 挂饰(背包问题)
[题目链接] http://www.lydsy.com/JudgeOnline/problem.php?id=4247 [题目大意] JOI君有N个装在手机上的挂饰,编号为1...N. JOI君可以将 ...
- BZOJ 4247 挂饰 01背包
题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=4247 JOI君有N个装在手机上的挂饰,编号为1...N. JOI君可以将其中的一些装在手机 ...
- bzoj 4247: 挂饰【dp】
bzoj上访问负下标会跑到奇怪的地方-- 其实可以滚动数组优化,但是我看能过就懒得改了 设f[i][j]为已经算了前i个挂饰,当前有j个空的钩子,转移就是f[i][j]=max(f[i-1][j],f ...
- BZOJ 4247: 挂饰 题解
Description JOI君有N个装在手机上的挂饰,编号为1...N. JOI君可以将其中的一些装在手机上. JOI君的挂饰有一些与众不同--其中的一些挂饰附有可以挂其他挂件的挂钩.每个挂件要么直 ...
- BZOJ 4247: 挂饰
背包裸题 #include<cstdio> #include<algorithm> using namespace std; int F[2005]; struct node{ ...
- BZOJ 4247: 挂饰 动态规划
按照挂件数量排序,然后做一个 DP 就好了. code: #include <bits/stdc++.h> #define ll long long #define N 2003 #def ...
- bzoj千题计划197:bzoj4247: 挂饰
http://www.lydsy.com/JudgeOnline/problem.php?id=4247 先把挂饰按挂钩数量从大到小排序 dp[i][j]前i个挂饰,剩下j个挂钩的最大喜悦值 分挂和不 ...
- bzoj4247: 挂饰(背包dp)
4247: 挂饰 Time Limit: 10 Sec Memory Limit: 256 MBSubmit: 1136 Solved: 454[Submit][Status][Discuss] ...
随机推荐
- php 实现店铺装修7
type_id=0的情况 type_id=1的情况 type_id=2的情况 /** * @title 店铺装修--商品分类 * @param type ...
- Lesson 5 Youth
How does the writer like to treat young people? People are always talking about 'the problem of yout ...
- Shortest and Longest LIS
Codeforces Round #620 (Div. 2) D. Shortest and Longest LIS 题解: 贪心即可,对于最短序列,我们尽可能用可用的最大数字放入序列中,对于最长序列 ...
- greenplum 导入数据方式
参考: http://gpdb.docs.pivotal.io/4390/admin_guide/load/topics/g-working-with-file-based-ext-tables.ht ...
- HTML学习第七天(一)
HTML学习第七天(一) aside元素用来表示当前或文章的附属信息部分,它可以包含与当前页面或主要内容的相关引用.侧边栏.广告.导航条,以及其他类似的有区别于主要内容的部分 <!DOCTYPE ...
- 实践 Network Policy 【转】
为了演示 Network Policy,我们先部署一个 httpd 应用,其配置文件 httpd.yaml 为: httpd 有三个副本,通过 NodePort 类型的 Service 对外提供服务. ...
- PyCharm配置TensorFlow开发环境
Anaconda自带的Jupyter Notebook很方便,但是执行速度较慢,缺少调试环境.PyCharm与Jupyter Notebook相比,执行速度更快,而且提供了类似Matlab的调试工具, ...
- STM32CubeIDE 编译C/C++程序
文章转自 https://www.cnblogs.com/skyofbitbit/p/3708216.html STM32CubeIDE 其实就是STM32CubeMx + eclipse 首先,W ...
- ubuntu18.04下载yarn
下载curl sudo apt-get update && sudo apt-get install curl 配置库 curl -sS https://dl.yarnpkg.com/ ...
- 关于http的两种上传方法
http传输数据GET和POST的两种方法: 1.Post传输数据时,不需要在URL中显示出来,而Get方法要在URL中显示. 2.get方式传递的参数可以在URL上看见,安全性不高,反之post安全 ...