codeforces 401B - Sereja and Contests

题目链接:http://codeforces.com/problemset/problem/401/B

题目大意:正在做第x场比赛,之前做过k场,判断之前最少和最多错过了几场比赛,连续的场次可能是同时举办比赛。

题目分析:div2可以单独举办,div1必须和div2一起(编号连续),其他没有什么需要注意了。

代码参考:

#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<cstring>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>
using namespace std;

const int N = 5000;
bool vis[N];
int  main()
{
	int n, m, t, i, j, k, div, a, b, c;

	while (~scanf("%d%d", &n, &m))
	{
		memset(vis, 0, sizeof(vis));

		for (i = 0; i < m; ++i)
		{
			scanf("%d", &div);

			if (div == 1)
			{
				scanf("%d%d", &a, &b);
				vis[a] = vis[b] = 1;
			}
			else
			{
				scanf("%d", &c);
				vis[c] = 1;
			}
		}

		int cnt = 0;

		int mx = 0, mi = 0;
		vis[n] = true;

		for (i = 1; i < n; ++i)
		{
			if (!vis[i])
			{
				++mx;
				++mi;

				if (!vis[i + 1])
				{
					++mx;
					++i;
				}
			}
		}

		int ans;

		if (cnt % 2 == 0)
		{
			ans = cnt / 2;
		}
		else
		{
			ans = cnt / 2 + 1;
		}

		printf("%d %d\n", mi, mx);
	}

	return 0;
}



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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值