The main thing about this problem is to read the topic. We need to figure out the shortest time to move the table, according to which we can tell that different rooms occupy the same corridor.
The 1-4,2-3 obviously occupies the same corridor, but 2-3 and 4-5 also occupy the corridor of Room 4 and room 3, so note that the minimum time for this data is 20, not 10. Make sure this is good to do, we can put the room even/2, odd/2+1, so 2-3 became 1-2,4-5 became 2-3, naturally occupied the corridor.
#include <stdio.h> #include <string.h> #define MAX (x, y) (x>y?x:y) #define MIN (x, y) (x<y?x:y) #define MAX 201int out[max];int Process (int x) {if (x%2) return x/2+1;else return X/2;} int main () {int t,i,j,n,from,to,res;scanf ("%d", &t), while (t--) {memset (out,0,sizeof (out)); scanf ("%d", &n); for (i=0;i<n;i++) {scanf ("%d%d", &from,&to), for (J=min (process (), process (to)), J<=max (Process ( From), process (to)); J + +) out[j]++;} Res =0;for (j=0;j<=max;j++) res = MAX (res,out[j]);p rintf ("%d\n", res*10);} return 0;}
POJ Miscellaneous Questions-1083 Moving Tables