POJ 1083 解题报告

这道题看着很难,看了discuss上面的这个这个讨论:

http://poj.org/showmessage?message_id=123867

后发现其实挺简单的。解法在上述链接中。

thestoryofsnow1083Accepted152K0MSC++962B

/* 
ID: thestor1 
LANG: C++ 
TASK: poj1083 
*/
#include <iostream>
#include <fstream>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <limits>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <cassert>

using namespace std;

const int NROOMS = 200;

int main()
{
	int T;
	scanf("%d", &T);
	int corridor[NROOMS] = {0};
	for (int no = 0; no < T; ++no)
	{
		memset(corridor, 0, sizeof(corridor));
		int N, s, t, tmp;
		scanf("%d", &N);
		for (int n = 0; n < N; ++n)
		{
			scanf("%d%d", &s, &t);
			if (s > t)
			{
				tmp = s, s = t, t = tmp;
			}
			if (s % 2 == 0)
			{
				s--;
			}
			if (t % 2 == 0)
			{
				t--;
			}
			s /= 2, t /= 2;
			for (int i = s; i <= t; ++i)
			{
				corridor[i]++;
			}
		}

		printf("%d\n", *max_element(corridor, corridor + NROOMS) * 10);
	}
	return 0;  
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值