题目分析
找出最多的重叠次数,把上下房间对着的看成一个地方,比如 1 , 2 1,2 1,2 看成都在1这个地方,$3 4 $,都在 2 2 2 这个地方 56 5 6 56 都在 3 3 3 这个地方,用数组记录出现每个数次数,找出次数出现最大值,最后乘以 10 10 10.
#include<iostream>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int MAX = 210;
int read() {
int f = 1, x = 0;
char c = getchar();
while (c < '0' || c > '9') {
if (c == '-')f = -1;
c = getchar();
}
while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
return f * x;
}
void write(int x) {
if (x < 0) {
putchar('-');
x = -x;
}
if (x > 9)write(x / 10);
putchar(x % 10 + '0');
}
int t = read(), n, d, f[MAX], k, m, m1, maxn;
int main() {
while (t--) {
n = read();
memset(f, 0, sizeof(f));
d = 10, maxn = 0;
for (int i = 1; i <= n; i++) {
m = read(), m1 = read();
if (m > m1)swap(m, m1);
m = (m + 1) / 2, m1 = (m1 + 1) / 2;
for (k = m; k <= m1; k++)
f[k]++;
}
for (int i = 1; i <= 200; i++)
maxn = max(maxn, f[i]);
printf("%d\n", maxn * 10);
}
return 0;
}