zoukankan      html  css  js  c++  java
  • POJ1083

    分析:房间1和2前面是同一个走廊,所以从1移动到2只需要占用一个走廊,房间2和3前面不是同一个走廊,因此从2移动到3需要占用2个走廊。基本思路是开辟一个200的数组,表示所有房间前面的走廊,每个元素初始化为0,如果从m移动到n(假设m<n,但是在程序中处理输入时需要判断两个数大小),则把序号为(m-1)/2到(n-1)/2的所有数组元素都+10。处理完每个桌子后,将数组进行排序,最大值即为所需时间。

     1 #include <iostream>
     2 #include <algorithm>
     3 using namespace std;
     4 
     5 int main()
     6 {
     7     int T;
     8     cin >> T;
     9     for (int i =0; i < T; i++)
    10     {
    11         int corridor[200] = {0};
    12         int N;
    13         cin >> N;
    14         for (int j = 0; j < N; j++)
    15         {
    16             int m, n;
    17             cin >> m >> n;
    18             if (m > n)
    19             {
    20                 for (int p = (n-1)/2; p <= (m-1)/2; p++)
    21                     corridor[p] += 10;
    22             }
    23             else
    24             {
    25                 for (int p = (m-1)/2; p <= (n-1)/2; p++)
    26                     corridor[p] += 10;
    27             }
    28         }
    29         sort(corridor, corridor+200);
    30         cout << corridor[199] << endl;
    31     }
    32     
    33     return 0;
    34 }
  • 相关阅读:
    webservice
    AppDomain (转)
    Apache和Nginx防盗链的几种配置方法
    优化PHP代码的40条建议
    file_get_contents无法请求https连接的解决方法
    PHP SPL
    Ubuntu 查看系统信息
    PHP导出Excel
    mysql集群
    配置yum源的两种方法
  • 原文地址:https://www.cnblogs.com/bournet/p/3971233.html
Copyright © 2011-2022 走看看