poj1083Moveing tables(简单DP)
2016-05-24 16:49
405 查看
把由j到i的转换成由i到j的来计算,然后因为走廊占据一个位置是要占两个房间的,所以移动一段占用的房间要加上两边对面的房间。 就这样,做了一个水题……(╯﹏╰)b
/*poj1083*/ #include <iostream> #include <cstdio> #include <cstring> using namespace std; int s[401]={0}; int res=0; int n; int i,j; int a,b; int main() { int T; scanf("%d",&T); while(T--) { memset(s,0,sizeof(s)); res=0; scanf("%d",&n); for(i=1;i<=n;++i) { scanf("%d%d",&a,&b); if(a>b) {int t=a;a=b;b=t;} if(!(a&1)) a--; if(b&1) b++; for(j=a;j<=b;++j) { s[j]++; //printf("%d\n",s[j]); } } for(i=1;i<=400;++i) if(s[i]>res) res=s[i]; res*=10; printf("%d\n",res); } return 0; }
相关文章推荐
- 苹果键盘打出 顿号
- ios UITableview 刷新某一个cell 或 section
- strcat()与strcpy()用法
- Dave(正方形能围成的最大点数)
- Task三个列子的分享
- HTML 30分钟入门教程
- android之自定义View和ViewGroup(四)(代码篇,实现圆形进度条)
- Jenkins配置基于角色的项目权限管理
- 【BZOJ1243】[Seerc2007]Showstopper【二分】
- vehicle detection haarcascades
- Windows下wamp sever+sendmail使用mail()函数时的配置
- HTML常用标签
- apache禁止访问默认虚拟主机
- scala中的孤立对象实现原理
- 深入理解Java之泛型
- Hadoop与Spark整合
- Hp服务器 iLO3 使用方法
- post 相比get 有很多优点,为什么现在的HTTP通信中大多数请求还是使用get?
- android检测导航栏是否存在的方法
- 4、Git暂存区