移桌 题解

题目分析

找出最多的重叠次数,把上下房间对着的看成一个地方,比如 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;
}
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值