poj3666
来源:互联网 发布:安卓ehviewer网络错误 编辑:程序博客网 时间:2024/06/13 16:30
#include <iostream>#include<cstdio>#include<algorithm>#include<string.h>#include<math.h>using namespace std;int n,a[2005],dp[2005][2005],b[2005];int main(){ scanf("%d",&n); for(int i=0;i<n;i++) { scanf("%d",&a[i]); b[i]=a[i]; } sort(b,b+n); memset(dp[0],0,sizeof(dp[0])); for(int j=1;j<=n;j++) { int m=1000000005; for(int i=0;i<n;i++) { m=min(dp[j-1][i],m); dp[j][i]=m+abs(a[j-1]-b[i]); } } int m=1000000005; for(int i=0;i<n;i++) { m=min(m,dp[n][i]); } printf("%d\n",m); return 0;}
数据比较弱,只需要求非递减数列
dp+离散化
0 0
- poj3666
- poj3666
- poj3666
- POJ3666
- poj3666
- poj3666+codeforces713C
- POJ3666---Making the Grade
- poj3666 Making the Grade
- poj3666(dp前缀优化)
- POJ3666(动态规划)
- poj3666 Making the Grade
- 动态规划--poj3666
- POJ3666-Making the Grade
- 【POJ3666】Making the Grade
- poj3666-基础DP
- poj3666 Making the Grade dp
- POJ3666 离散化的dp
- POJ3666-Making the Grade-dp
- 64win7 oracle plsql 无连接为显示以及乱码
- 【Android】Android中AlertDialog对话框的使用实例
- LookUp下拉框 EOleException 未知错误
- 快速排序
- flex LCDS
- poj3666
- 【DB.PL/SQL】数据类型 —— 字符串
- [Plan]博客第一周
- Apache ab的使用
- Yum出错Error: Cannot find a valid baseurl for repo: base
- 【cocos2dx 3.2】Flappy Bird开发超详细讲解(四)让地图滚动起来吧
- 虚拟机上-ubuntu安装openssh-server 报依赖错误的解决过程
- 钱帮主:理财方式多样化,投资利益高收化。
- .net中的泛型