poj 1083 moving tables 【动态规划】
2015-11-11 20:56
309 查看
题目链接:http://poj.org/problem?id=1083
分析:
一层楼上有400个房间,南边跟北边每边各200个,现在要在房间之间移动一些桌子,但是过道太窄了,每次只能通过一个,要求的是搬运一些桌子要花的最短时间,过道不冲突的话可以同时搬。
代码:
分析:
一层楼上有400个房间,南边跟北边每边各200个,现在要在房间之间移动一些桌子,但是过道太窄了,每次只能通过一个,要求的是搬运一些桌子要花的最短时间,过道不冲突的话可以同时搬。
代码:
#include<stdio.h> #include<string.h> #define N 220 void swap(int &a,int &b) { int t; t=a; a=b; b=t; } int main() { int i,j; int t,n,from,to,max,min; int room ; scanf("%d",&t); while(t--) { scanf("%d",&n); memset(room,0,sizeof(room)); for(i=0;i<n;i++) { scanf("%d%d",&from,&to); if(from>to) swap(from,to); from=(from+1)/2; to=(to+1)/2; for(j=from;j<=to;j++) room[j]++; } min=0; for(i=1;i<N;i++) { if(room[i]>=min) min=room[i]; } printf("%d\n",min*10); } getchar(); return 0; }
相关文章推荐
- 求二维数组的鞍点
- iOS学习笔记--如何为UITextView设置placeholder
- SoapUI启动报错:The JVM could not be started. The maximum heap size (-Xmx) might be too large
- android view的setVisibility方法值的意思
- mysql之触发器的使用
- Myhabtis学习笔记(一)
- 安卓中 dp\px\sp的区别
- thinkphp通过浏览器ua信息判断访客为手机端或PC端的方法
- T006 奖金
- Java 集合
- 过山车(最大匹配)
- 记录
- RxJava 入门
- spring 官方下载地址(Spring Framework 3.2.x&Spring Framework 4.0.x
- Python的文件操作
- T005 判断回文数
- OC的内存管理方式----MRC & ARC
- CSS三栏布局(两边固定中间自适应宽度)的方法
- eclipse快捷键
- Python编写微信打飞机小游戏(五)