2009_Round_1C_C
来源:互联网 发布:系统 数据库备份策略 编辑:程序博客网 时间:2024/06/03 22:42
//bribe the prisoners
//http://blog.csdn.net/lizo_is_me/article/details/43735509
//compute the sub item first , then left_cost+right_cost+item(i->j)-1 =>cost of bribe i->j
//dp+iterate
//http://blog.csdn.net/lizo_is_me/article/details/43735509
//compute the sub item first , then left_cost+right_cost+item(i->j)-1 =>cost of bribe i->j
//dp+iterate
//bribe the prisoners//http://blog.csdn.net/lizo_is_me/article/details/43735509//compute the sub item first , then left_cost+right_cost+item(i->j)-1 =>cost of bribe i->j//dp+iterate#include<iostream>#define inf 0x7fffffffusing namespace std;int a[maxn+10],cost[maxn+10][maxn+10];void solve(){ a[0]=0,a[n+1]=n+1; for(int i=0;i<n+1;i++){ cost[i][i+1]=0; } for(int w=2;w<=n+1;w++){ for(int i=0;i+w<=n+1;i++){ int j=i+w,temp=inf; for(int k=i+1;k<j;k++){ temp=min(temp,cost[i][k]+cost[k][j]); } cost[i][j]=temp+a[j]-a[i]-1-1; //first for a[j]-a[i]-1(not include border),the other for minus itself } } cout<<cost[0][n+1];}
0 0
- 2009_Round_1C_C
- 2009
- 2009
- 2009
- 2009
- 2009
- 2009
- 2009
- 2009
- 2009
- 2009
- 2009
- 2009
- 2009
- 2009
- 2009^2009运算问题
- Welcome 2009!
- 2008-2009
- redis实现分布式锁
- Android 通知栏Notification的整合 全面学习 (一个DEMO让你完全了解它)
- 【第三周 项目2-“顺序表”算法库】
- 问题
- Vitamio库打造万能播放器(四)
- 2009_Round_1C_C
- 15章实现会员注册升级
- OpenGL基本概念入门——纹理贴图
- 【NOIP2016提高A组模拟9.17】序列
- 链表的反转
- you appear to be running an x server please exit x before installing
- oracle11g linux安装准备
- 脚本编写教程
- C/C++ sizeof详解