UVALive-2326 Moving Tables Greedy

Source: Internet
Author: User

The main topic: There are 400 boxes, odd boxes in the North, even the box in the south, the size of each box is the same. There is a corridor between the north and the south, and the width of the corridor is just the width of a box.
There are now M mobile operations, workers each move the box takes 10 minutes (you have unlimited workers, because there are corridor constraints, can not have two boxes common a corridor). Ask how many minutes it takes to get these things done.

Problem-solving ideas: First the odd boxes and even-numbered boxes to deal with, to avoid 1 3 and 4 6 operation only need 10 minutes of this situation. When entering, be aware that the first number entered may be less than the second number.

#include <cstdio>#include <cstring>#include <algorithm>using namespace STD;Const intN = About;structroom{intx, y;} R[n];intn, Vis[n];intcmpConst&a,Const&AMP;B) {if(a.x = = b.x) {returnA.y > B.y; }Else        returna.x < b.x;}voidInit () {scanf("%d", &n);intx, y; for(inti =0; I < n; i++) {scanf("%d%d", &x, &y);if(x > Y) {intt = x;            x = y;        y = t; } r[i].x = x%2? X:X-1; R[i].y = y%2? Y:y-1; } sort (r, R + N, CMP);memset(Vis,0,sizeof(VIS));}intSolve () {intCNT =0;intMark =0; while(1) {intL =-Ten; for(inti =0; I < n; i++) {if(!vis[i] && r[i].x > L) {Vis[i] =1;                 L = r[i].y;            mark++; }} cnt++;if(Mark = = N) Break; }returnCNT *Ten;}intMain () {intTestscanf("%d", &test); while(test--) {init ();printf("%d\n", solve ()); }return 0;}

UVALive-2326 Moving Tables Greedy

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.