A12773 | Badges
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
There are $b$ boys and $g$ girls participating in Olympiad of Metropolises. There will be a board games tournament in the evening and $n$ 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+1$ decks of badges. The $i$ -th (where $i$ is from $0$ to $n$ , inclusive) deck contains $i$ blue badges and $n-i$ red ones. The total number of badges in any deck is exactly $n$ .
Determine the minimum number of decks among these $n+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.
Organizers are preparing red badges for girls and blue ones for boys.
Vasya prepared $n+1$ decks of badges. The $i$ -th (where $i$ is from $0$ to $n$ , inclusive) deck contains $i$ blue badges and $n-i$ red ones. The total number of badges in any deck is exactly $n$ .
Determine the minimum number of decks among these $n+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.
输入格式
The first line contains an integer $b$ ( $1 \le b \le 300$ ), the number of boys.
The second line contains an integer $g$ ( $1 \le g \le 300$ ), the number of girls.
The third line contains an integer $n$ ( $1 \le n \le b + g$ ), the number of the board games tournament participants.
The second line contains an integer $g$ ( $1 \le g \le 300$ ), the number of girls.
The third line contains an integer $n$ ( $1 \le n \le b + g$ ), the number of the board games tournament participants.
输出格式
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.
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.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted