您的位置:首页 > 其它

hdu 1050 Moving Tables

2016-02-08 20:43 423 查看
http://acm.hdu.edu.cn/showproblem.php?pid=1050

简单的题目,就是求交叉的路线最多次数。

注意:

房间可能从大到小,也可能从小到大。

1和2属于同一个,2和3也是。。。。等等

#include<iostream>
using namespace std;
int n,m,a[405];
int main(){
int temp1, temp2;
cin >> n;
while (n--)
{
memset(a, 0, sizeof(a));
int max = 0;
cin >> m;
for (int i = 0; i < m; i++){
cin >> temp1 >> temp2;
if (temp1>temp2){
int temp = temp1;
temp1 = temp2;
temp2 = temp;
}
if (!(temp1 % 2))
temp1 = temp1 - 1;
if (temp2 % 2)
temp2 = temp2 + 1;
for (int j = temp1; j <= temp2; j++){
a[j]++;
max = a[j] > max ? a[j] : max;
}
}
cout << max*10 << endl;
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: