CF1214B.Badges

普及-

通过率:0%

时间限制:1.00s

内存限制:512MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

There are bb boys and gg girls participating in Olympiad of Metropolises. There will be a board games tournament in the evening and nn participants have accepted the invitation. The organizers do not know how many boys and girls are among them.

Organizers are preparing red badges for girls and blue ones for boys.

Vasya prepared n+1n+1 decks of badges. The ii-th (where ii is from 00 to nn, inclusive) deck contains ii blue badges and n−in-i red ones. The total number of badges in any deck is exactly nn.

Determine the minimum number of decks among these n+1n+1 that Vasya should take, so that there will be a suitable deck no matter how many girls and boys there will be among the participants of the tournament.

有 bb 名男生和 gg 名女生参加“大都市奥林匹克竞赛”。当晚将举行一场棋类游戏锦标赛,共有 nn 名参与者接受了邀请。组织者尚不清楚其中男生和女生各有多少人。

组织者为女生准备红色徽章,为男生准备蓝色徽章。

瓦夏准备了 n+1n+1 套徽章。第 ii 套(其中 ii 的取值范围为 00 到 nn,含端点)包含 ii 枚蓝色徽章和 n−in-i 枚红色徽章。每套徽章的总数恰好为 nn 枚。

请确定:在全部 n+1n+1 套徽章中,瓦夏至少需要取多少套,才能确保无论参赛者中男生与女生的具体人数如何,总有一套徽章是适用的。

输入格式

The first line contains an integer bb (1≤b≤3001 \le b \le 300), the number of boys.

The second line contains an integer gg (1≤g≤3001 \le g \le 300), the number of girls.

The third line contains an integer nn (1≤n≤b+g1 \le n \le b + g), the number of the board games tournament participants.

第一行包含一个整数 bb(1≤b≤3001 \le b \le 300),表示男生人数。
第二行包含一个整数 gg(1≤g≤3001 \le g \le 300),表示女生人数。
第三行包含一个整数 nn(1≤n≤b+g1 \le n \le b + g),表示棋类比赛参赛者人数。

输出格式

Output the only integer, the minimum number of badge decks that Vasya could take.

输出唯一的整数,即瓦西娅可能携带的徽章牌组的最少数量。

输入输出样例

  • 输入#1

    5
    6
    3

    输出#1

    4
  • 输入#2

    5
    3
    5

    输出#2

    4

说明/提示

In the first example, each of 4 decks should be taken: (0 blue, 3 red), (1 blue, 2 red), (2 blue, 1 red), (3 blue, 0 red).

In the second example, 4 decks should be taken: (2 blue, 3 red), (3 blue, 2 red), (4 blue, 1 red), (5 blue, 0 red). Piles (0 blue, 5 red) and (1 blue, 4 red) can not be used.

在第一个例子中,应选取 4 堆牌,分别为:(0(0 枚蓝色,33 枚红色))、(1(1 枚蓝色,22 枚红色))、(2(2 枚蓝色,11 枚红色))、(3(3 枚蓝色,00 枚红色))。

在第二个例子中,应选取 4 堆牌,分别为:(2(2 枚蓝色,33 枚红色))、(3(3 枚蓝色,22 枚红色))、(4(4 枚蓝色,11 枚红色))、(5(5 枚蓝色,00 枚红色))。堆 (0(0 枚蓝色,55 枚红色)) 和 (1(1 枚蓝色,44 枚红色)) 不可使用。

输入解题思路,AI测评打分。不知道怎么写?

首页