[BZOJ4247] 挂饰
来源:互联网 发布:淘宝店商品下架上架 编辑:程序博客网 时间:2024/05/22 14:26
传送门
http://www.lydsy.com/JudgeOnline/problem.php?id=4247
题目大意
给定
题解
注意处置
const maxn=2005;var dp:array[0..maxn,0..2*maxn]of longint; x,y:array[0..maxn]of longint; i,j,k:longint; n,m,ans:longint;function max(a,b:longint):longint;begin if a>b then exit(a) else exit(b); end;procedure sort(l,r:longint);var a,b,i,j:longint;begin i:=l; j:=r; a:=x[(l+r)div 2]; repeat while x[i]>a do inc(i); while a>x[j] do dec(j); if not(i>j) then begin b:=x[i]; x[i]:=x[j]; x[j]:=b; b:=y[i]; y[i]:=y[j]; y[j]:=b; inc(i); dec(j); end; until i>j; if l<j then sort(l,j); if i<r then sort(i,r);end;begin readln(n); for i:=1 to n do readln(x[i],y[i]); sort(1,n); {x[i]} for i:=0 to n do for j:=0 to n+1 do dp[i,j]:=-1000000000; dp[0,1]:=0; for i:=1 to n do for j:=0 to n do dp[i,j]:=max(dp[i-1,j],dp[i-1,max(0,j-x[i])+1]+y[i]); ans:=0; for i:=0 to n do ans:=max(ans,dp[n,i]); writeln(ans);end.
0 0
- 【BZOJ4247】挂饰
- bzoj4247 挂饰
- BZOJ4247: 挂饰
- [BZOJ4247] 挂饰
- 【BZOJ4247】挂饰
- bzoj4247: 挂饰
- bzoj4247 挂饰 背包DP
- bzoj4247: 挂饰(01背包)
- 【BZOJ4247】挂饰,又一个奇特的背包
- 4247: 挂饰
- 挂饰 BZOJ
- BZOJ 4247 挂饰 背包
- A-挂饰|01背包
- [DP] BZOJ 4247 挂饰
- bzoj 4247: 挂饰
- BZOJ 4247(挂饰-背包)
- 【BZOJ】【P4247】【挂饰】【题解】【背包】
- BZOJ 4247: 挂饰|动态规划
- Python OOP知识积累
- Jpeglib读取jpg文件
- ServletConfig和ServletContext
- Network 【OAuth 认证流程详解】
- qpainter的实质
- [BZOJ4247] 挂饰
- 【Android】安卓学习笔记之提升ListView 的运行效率
- easyUI 布局
- UVa--11181 Probability|Given(math)
- python和flask如何在linux上创建应用
- iOS 【UIKit-iOS常用控件尺寸大集合 】
- 架构
- iOS部分 理论:
- 欢迎使用CSDN-markdown编辑器