1000-A

来源:互联网 发布:初中化学软件有哪些 编辑:程序博客网 时间:2024/06/06 01:44
        1.题目编号:1000-A

2.简单题意:一共两侧房间,每一侧各200个,从一个房间搬东西到另一个房间,走廊一次只能搬一个,每次话费10分钟,给出从哪个房间搬到哪个房间,求最短搬得时间。

3.解题思路形成过程:把两排房间看成一排,定义一个200的数组,每段房间经过的房间,便将数组对应的加1,最后得出的得数组最大的数乘以时间,便是最短时间。
4.感想:这道题老师上课讲了,好多知识虽然不能都等老师讲,但是上课听讲很重要,做题要灵活,多思考。 

5.AC代码:

#include<iostream>#include<cstring>using namespace std;int main(){   int n,m,t;   int from,to;    int mov[200];    cin>>n;    while(n--)    {        cin>>m;        memset(mov,0,sizeof(mov));        for(int i=0;i<m;++i)        {            cin>>from>>to;            from=(from-1)/2;            to=(to-1)/2;            if(from>to)            {                t=from;                from=to;                to=t;             }            for(int j=from;j<=to;j++)            {                 mov[j]++;            }         }         int js=0;         for(int i=0;i<200;i++)         {              if(mov[i]>js)              {js=mov[i];}          }         cout<<js*10<<endl;    }         return 0;}


0 0