您的位置:首页 > 其它

poj 1083 moving tables 【动态规划】

2015-11-11 20:56 309 查看
题目链接:http://poj.org/problem?id=1083

分析:

一层楼上有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;
}



内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: