UVA 1625 Color Length
来源:互联网 发布:网络协议实践加密技术 编辑:程序博客网 时间:2024/04/30 17:10
#include<iostream>#include<cstdio>#include<string>#include<cstring>#include<algorithm> #include<cmath>#include<vector>using namespace std;const int maxn=1000+5;int L,N,C[maxn],d[maxn][maxn];int dp(int left,int right){int& ans=d[left][right];if(ans!=-1) return ans;ans=(1<<30);int ok=0; //标记改段是否可以被锯掉 for(int i=0;i<N;i++)if(left<C[i]&&right>C[i]){ans=min(ans,dp(left,C[i])+dp(C[i],right)+right-left);ok=1; }return ok?ans:ans=0;}int main(){while(cin>>L&&L){cin>>N;for(int i=0;i<N;i++) cin>>C[i];memset(d,-1,sizeof(d));printf("The minimum cutting is %d.\n",dp(0,L));}return 0;}
0 0
- Uva-1625-Color Length
- UVA 1625 Color Length
- UVA-1625 Color Length
- uva 1625 color length
- UVA 1625 Color Length
- UVA 1625 Color Length
- UVA 1625 Color Length
- UVa 1625 Color Length
- UVA 1625 Color Length
- UVA 1625 Color Length
- Color Length - UVa 1625 dp
- UVa OJ 1625 - Color Length
- uva 1625 Color Length (dp)
- UVa #1625 Color Length (例题9-8)
- UVA 1625 Color Length (DP)
- UVa 1625:Color Length(DP)
- uva 1625——Color Length
- Color Length UVA
- STL Vector remove()和erase()的使用
- thinkphp学习之入门一
- CodeForces 166A Rank List
- YII2.0 UrlHelper
- iOS音频编程之实时语音通信
- UVA 1625 Color Length
- TCP连接心跳机制
- Cocos2d-x 事件分发机制
- Dubbo zookeeper:Will not attempt to authenticate using SASL (unknown error)
- 音乐播放器开发过程——连载
- java导出Excel
- linux 入门 - 双系统的安装&JDK环境配置&Android Studio 的安装使用
- Python实现Singleton模式
- Arduino - 5V供电注意事项