Sereja and Contests(模拟)

B. Sereja and Contests
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

Sereja is a coder and he likes to take part in Codesorfes rounds. However, Uzhland doesn't have good internet connection, so Sereja sometimes skips rounds.

Codesorfes has rounds of two types: Div1 (for advanced coders) and Div2 (for beginner coders). Two rounds, Div1 and Div2, can go simultaneously, (Div1 round cannot be held without Div2) in all other cases the rounds don't overlap in time. Each round has a unique identifier — a positive integer. The rounds are sequentially (without gaps) numbered with identifiers by the starting time of the round. The identifiers of rounds that are run simultaneously are different by one, also the identifier of the Div1 round is always greater.

Sereja is a beginner coder, so he can take part only in rounds of Div2 type. At the moment he is taking part in a Div2 round, its identifier equals to x. Sereja remembers very well that he has taken part in exactly k rounds before this round. Also, he remembers all identifiers of the rounds he has taken part in and all identifiers of the rounds that went simultaneously with them. Sereja doesn't remember anything about the rounds he missed.

Sereja is wondering: what minimum and what maximum number of Div2 rounds could he have missed? Help him find these two numbers.

Input

The first line contains two integers: x (1 ≤ x ≤ 4000) — the round Sereja is taking part in today, and k (0 ≤ k < 4000) — the number of rounds he took part in.

Next k lines contain the descriptions of the rounds that Sereja took part in before. If Sereja took part in one of two simultaneous rounds, the corresponding line looks like: "1 num2 num1" (where num2 is the identifier of this Div2 round, num1 is the identifier of the Div1round). It is guaranteed that num1 - num2 = 1. If Sereja took part in a usual Div2 round, then the corresponding line looks like: "2num" (where num is the identifier of this Div2 round). It is guaranteed that the identifiers of all given rounds are less than x.

Output

Print in a single line two integers — the minimum and the maximum number of rounds that Sereja could have missed.

Sample test(s)
input
3 2
2 1
2 2
output
0 0
input
9 3
1 2 3
2 8
1 4 5
output
2 3
input
10 0
output
5 9
Note

In the second sample we have unused identifiers of rounds 1, 6, 7. The minimum number of rounds Sereja could have missed equals to 2. In this case, the round with the identifier 1 will be a usual Div2 round and the round with identifier 6 will be synchronous with the Div1round.

The maximum number of rounds equals 3. In this case all unused identifiers belong to usual Div2 rounds.

 

    题意:

    给出 X (1 ~ 4000)和 K (0 ~ 4000),代表有 X 场比赛,曾经参加过 K 场。比赛场次有两种 Div 2 和 Div 1,Div 1一定要伴随 Div 2 进行。后给出这 K 场的序号,若首数字为 1 ,则后面两个数字位 Div 2 和Div 1的场次,若首数字为2,则后面的数说明是Div 2的场次。问在 X 之前,未确定的场次最少和最多分别能进行多少场 Div 2的比赛。

 

    思路:

    模拟。

 

    AC:

#include <stdio.h>
#include <string.h>
int round[4005];

int main() {
    memset(round,0,sizeof(round));
    int n,m;
    scanf("%d%d",&n,&m);
    while(m--) {
        int ans;
        scanf("%d",&ans);
        if(ans == 2) {
            int num2;
            scanf("%d",&num2);
            round[num2] = 1;
        }else if(ans == 1) {
            int num1,num2;
            scanf("%d%d",&num2,&num1);
            round[num2] = 1;
            round[num1] = 1;
        }
    }

    int min_r = 0,max_r = 0;
    for(int i = 1;i < n;i++)
        if(!round[i])   max_r++;

    int sum = 0;
    for(int i = 1;i < n;i++) {
        if(sum && round[i]) {
            min_r += (sum / 2 + sum % 2);
            sum = 0;
        }
        if(!round[i]) sum++;
    }

    if(!round[n - 1] && sum) {
        min_r += (sum / 2 + sum % 2);
    }

    printf("%d %d\n",min_r,max_r);
    return 0;
}

 

 

 

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值