您当前的位置: 首页 > 

钟钟终

暂无认证

  • 5浏览

    0关注

    232博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

第二周--贪心题解(G)

钟钟终 发布时间:2021-03-15 18:53:21 ,浏览量:5

题G:

The famous ACM (Advanced Computer Maker) Company has rented a floor of a building whose shape is in the following figure.

The floor has 200 rooms each on the north side and south side along the corridor. Recently the Company made a plan to reform its system. The reform includes moving a lot of tables between rooms. Because the corridor is narrow and all the tables are big, only one table can pass through the corridor. Some plan is needed to make the moving efficient. The manager figured out the following plan: Moving a table from a room to another room can be done within 10 minutes. When moving a table from room i to room j, the part of the corridor between the front of room i and the front of room j is used. So, during each 10 minutes, several moving between two rooms not sharing the same part of the corridor will be done simultaneously. To make it clear the manager illustrated the possible cases and impossible cases of simultaneous moving.

For each room, at most one table will be either moved in or moved out. Now, the manager seeks out a method to minimize the time to move all the tables. Your job is to write a program to solve the manager’s problem. Input The input consists of T test cases. The number of test cases ) (T is given in the first line of the input. Each test case begins with a line containing an integer N , 1>n; for(int i=0;i>a[i].x>>a[i].y; if(a[i].x>a[i].y) { int temp=a[i].y; a[i].x=a[i].y; a[i].y=temp; } } sort(a,a+n,cmp); int time=10; for(int i=1;ia[i].y; if(a[i].x>a[i].y) { int temp=a[i].y; a[i].x=a[i].y; a[i].y=temp; } } sort(a,a+n,cmp); int time=10; for(int i=1;i

关注
打赏
1664378814
查看更多评论
立即登录/注册

微信扫码登录

0.0481s