Transportation-POJ 1040
来源:互联网 发布:2年java掌握的技术 编辑:程序博客网 时间:2024/05/22 07:44
DFS练习题,直接暴力吧,600+MS过的。。。。不能DP,有后效性,还有以后少用memcpy了,复杂度好大。。。。。
#include<cstdio>#include<cstring>#include<iostream>using namespace std;int max_size,n,m;#define MAXD 100 + 10#define max(a,b) (a > b? a: b)int state[MAXD];int ans;struct Route{ int x; int y; int per;}Stop[MAXD];void solve(int u,int money){ if(u == m){ ans = max(ans,money); return ; } solve(u + 1,money); /*不选择这个订单*/ int x = Stop[u].x; int y = Stop[u].y; int p = Stop[u].per; int i; for(int i = x ; i < y ; i ++){ state[i] += p; if(state[i] > max_size){ for(int j = i ; j >= x ; j--) state[j] -= p; return ; } } solve(u + 1,(y - x) * p + money); for(int i = y - 1; i >= x ; i --) state[i] -= p; return ;}int main(){ while(scanf("%d%d%d",&max_size,&n,&m)){ if(!max_size && !n && !m) break; memset(state,0,sizeof(state)); ans = 0; for(int i = 0 ; i < m ; i++) scanf("%d%d%d",&Stop[i].x,&Stop[i].y,&Stop[i].per); solve(0,0); printf("%d\n",ans); } return 0 ;}
0 0
- poj 1040 Transportation
- poj 1040 Transportation
- POJ-1040-Transportation
- Transportation-POJ 1040
- POJ 1040 Transportation DFS
- POJ 1040 Transportation
- poj-1040-Transportation
- POJ 1040 Transportation 笔记
- poj 1040 Transportation DFS剪枝
- UVA 301 POJ 1040- Transportation DFS 回溯
- UVa 301 & HDU 1456 & POJ 1040 - Transportation
- poj 1040 Transportation 深搜剪枝
- POJ 1797 Heavy Transportation
- POJ 1797 Heavy Transportation
- poj 1797Heavy Transportation
- poj 3228 Gold Transportation
- poj 1797 Heavy Transportation
- POJ 1797 Heavy Transportation
- ERP系统的主要分类及区别
- textview 单行显示且最多一行显示字数其余用省略号代替
- 计算机应用知识,什么是Ose.exe程序解析?
- MongoDB Shell 常用操作
- sqlite常用命令
- Transportation-POJ 1040
- 02-保存会出现builder窗口,导致Myeclipse运行缓慢解决方法
- 解决注册.net4.0时出现Changing IIS ApplicationHost.config
- 14.5 instanceof 与 Class的等价性
- c# 截取字符串和分割字符串
- android 中的编码和加密
- android移植笔记(1)
- SQLServer 错误: 15404,无法获取有关 Windows NT 组/用户 'WIN【转】
- java划分算法