A13805 | Rock, Paper, Scissors
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Alice and Bob have decided to play the game "Rock, Paper, Scissors".
The game consists of several rounds, each round is independent of each other. In each round, both players show one of the following things at the same time: rock, paper or scissors. If both players showed the same things then the round outcome is a draw. Otherwise, the following rules applied:
- if one player showed rock and the other one showed scissors, then the player who showed rock is considered the winner and the other one is considered the loser;
- if one player showed scissors and the other one showed paper, then the player who showed scissors is considered the winner and the other one is considered the loser;
- if one player showed paper and the other one showed rock, then the player who showed paper is considered the winner and the other one is considered the loser.
Alice and Bob decided to play exactly $n$ rounds of the game described above. Alice decided to show rock $a_1$ times, show scissors $a_2$ times and show paper $a_3$ times. Bob decided to show rock $b_1$ times, show scissors $b_2$ times and show paper $b_3$ times. Though, both Alice and Bob did not choose the sequence in which they show things. It is guaranteed that $a_1 + a_2 + a_3 = n$ and $b_1 + b_2 + b_3 = n$ .
Your task is to find two numbers:
1. the minimum number of round Alice can win;
2. the maximum number of rounds Alice can win.
The game consists of several rounds, each round is independent of each other. In each round, both players show one of the following things at the same time: rock, paper or scissors. If both players showed the same things then the round outcome is a draw. Otherwise, the following rules applied:
- if one player showed rock and the other one showed scissors, then the player who showed rock is considered the winner and the other one is considered the loser;
- if one player showed scissors and the other one showed paper, then the player who showed scissors is considered the winner and the other one is considered the loser;
- if one player showed paper and the other one showed rock, then the player who showed paper is considered the winner and the other one is considered the loser.
Alice and Bob decided to play exactly $n$ rounds of the game described above. Alice decided to show rock $a_1$ times, show scissors $a_2$ times and show paper $a_3$ times. Bob decided to show rock $b_1$ times, show scissors $b_2$ times and show paper $b_3$ times. Though, both Alice and Bob did not choose the sequence in which they show things. It is guaranteed that $a_1 + a_2 + a_3 = n$ and $b_1 + b_2 + b_3 = n$ .
Your task is to find two numbers:
1. the minimum number of round Alice can win;
2. the maximum number of rounds Alice can win.
输入格式
The first line of the input contains one integer $n$ ( $1 \le n \le 10^{9}$ ) — the number of rounds.
The second line of the input contains three integers $a_1, a_2, a_3$ ( $0 \le a_i \le n$ ) — the number of times Alice will show rock, scissors and paper, respectively. It is guaranteed that $a_1 + a_2 + a_3 = n$ .
The third line of the input contains three integers $b_1, b_2, b_3$ ( $0 \le b_j \le n$ ) — the number of times Bob will show rock, scissors and paper, respectively. It is guaranteed that $b_1 + b_2 + b_3 = n$ .
The second line of the input contains three integers $a_1, a_2, a_3$ ( $0 \le a_i \le n$ ) — the number of times Alice will show rock, scissors and paper, respectively. It is guaranteed that $a_1 + a_2 + a_3 = n$ .
The third line of the input contains three integers $b_1, b_2, b_3$ ( $0 \le b_j \le n$ ) — the number of times Bob will show rock, scissors and paper, respectively. It is guaranteed that $b_1 + b_2 + b_3 = n$ .
输出格式
Print two integers: the minimum and the maximum number of rounds Alice can win.
输入输出样例
输入 #1
2 0 1 1 1 1 0
输出 #1
0 1
输入 #2
15 5 5 5 5 5 5
输出 #2
0 15
输入 #3
3 0 0 3 3 0 0
输出 #3
3 3
输入 #4
686 479 178 29 11 145 530
输出 #4
22 334
输入 #5
319 10 53 256 182 103 34
输出 #5
119 226
In the first example, Alice will not win any rounds if she shows scissors and then paper and Bob shows rock and then scissors. In the best outcome, Alice will win one round if she shows paper and then scissors, and Bob shows rock and then scissors.
In the second example, Alice will not win any rounds if Bob shows the same things as Alice each round.
In the third example, Alice always shows paper and Bob always shows rock so Alice will win all three rounds anyway.
In the second example, Alice will not win any rounds if Bob shows the same things as Alice each round.
In the third example, Alice always shows paper and Bob always shows rock so Alice will win all three rounds anyway.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted