First, I will use the conventional greed, and the idea of watching more complete programs as much as possible. But ....... Always WA .... T_T ....
I searched this question on the Internet and found that many people had problems and did not find it. Basically, I used the method of sorting the tail.
In fact, this question is because there are two rows of rooms, so 1 and 2 Share a corridor, one of which cannot be moved when moving.
So I changed my mind later and directly changed it to finding the most overlapping parts in the two orders. (The corridor issue should also be handled during tail sorting .)
AC code:
# Include <iostream> # include <cstdio> # include <cstring> # include <algorithm> using namespace std; struct Node {int s, t; int p ;} a [210]; bool cmp (Node a, Node B) {return. t <B. t;} int main () {int t, n, I, j, tim, ma; scanf ("% d", & t); while (t --) {scanf ("% d", & n); for (I = 0; I <n; I ++) {a [I]. p = 0; scanf ("% d", & a [I]. s, & a [I]. t); a [I]. s = (a [I]. s + 1)/2; // handle the situation where parity is shared by a single walk (this has not been considered, so WA) a [I]. t = (a [I]. t + 1)/2; if (a [I]. s> a [I]. t) // guarantee s <t {j = a [I]. s; a [I]. s = a [I]. t; a [I]. t = j ;}} sort (a, a + n, cmp); ma = 0; for (I = 0; I <n; I ++) {tim = 1; for (j = I + 1; j <n; j ++) {if (a [j]. s <= a [I]. t) // determine whether there is an overlap {tim ++; // Add an overlap} if (tim> ma) {ma = tim ;}} printf ("% d \ n", ma * 10);} return 0 ;}