hdu 1050 Moving Tables

来源:互联网 发布:多益网络加班怎么样 编辑:程序博客网 时间:2024/06/01 09:23

http://acm.hdu.edu.cn/showproblem.php?pid=1050

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

  1. 房间可能从大到小,也可能从小到大。
  2. 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;}
0 0
原创粉丝点击