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&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