problem

E. Rock, Paper, Scissors
time limit per test1 second
memory limit per test256 megabytes
inputstandard input
outputstandard output
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 a1 times, show scissors a2 times and show paper a3 times. Bob decided to show rock b1 times, show scissors b2 times and show paper b3 times. Though, both Alice and Bob did not choose the sequence in which they show things. It is guaranteed that a1+a2+a3=n and b1+b2+b3=n.

Your task is to find two numbers:

the minimum number of round Alice can win;
the maximum number of rounds Alice can win.
Input
The first line of the input contains one integer n (1≤n≤109) — the number of rounds.

The second line of the input contains three integers a1,a2,a3 (0≤ai≤n) — the number of times Alice will show rock, scissors and paper, respectively. It is guaranteed that a1+a2+a3=n.

The third line of the input contains three integers b1,b2,b3 (0≤bj≤n) — the number of times Bob will show rock, scissors and paper, respectively. It is guaranteed that b1+b2+b3=n.

Output
Print two integers: the minimum and the maximum number of rounds Alice can win.

Examples
inputCopy
2
0 1 1
1 1 0
outputCopy
0 1
inputCopy
15
5 5 5
5 5 5
outputCopy
0 15
inputCopy
3
0 0 3
3 0 0
outputCopy
3 3
inputCopy
686
479 178 29
11 145 530
outputCopy
22 334
inputCopy
319
10 53 256
182 103 34
outputCopy
119 226
Note
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.

solution

/*
题意:
+ 石头剪刀布,进行n轮。给出a1,a2,a3,b1,b2,b3分别表示A和B总共出的三种的次数(加起来为n)
+ 求A可以获胜的最小次数和最大次数。
思路:
+ A赢的最大次数可以直接算,每次都让B出对应被A克的累加就行。
+ 但是A赢的情况不能直接算B获胜次数,还有平局,所以直接拿n-B输了的状态和a取最小累加。
*/
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn = 1e6+10;
const int mod = 998244353;
int main(){int n,a1,a2,a3,b1,b2,b3;cin>>n>>a1>>a2>>a3>>b1>>b2>>b3;int ans1 = min(a1,n-b2)+min(a2,n-b3)+min(a3,n-b1);int ans2 = min(a1,b2)+min(a2,b3)+min(a3,b1);cout<<n-ans1<<" "<<ans2<<"\n";return 0;
}

【Codeforces 1426 E】Rock, Paper, Scissors,贪心!算反面相关推荐

  1. 2018 ACM-ICPC 中国大学生程序设计竞赛线上赛 H题 Rock Paper Scissors Lizard Spock.(FFT字符串匹配)...

    2018 ACM-ICPC 中国大学生程序设计竞赛线上赛:https://www.jisuanke.com/contest/1227 题目链接:https://nanti.jisuanke.com/t ...

  2. 2021年度训练联盟热身训练赛第四场 H - Rock Paper Scissors(字符串匹配,FFT)

    整理的算法模板合集: ACM模板 点我看算法全家桶系列!!! 实际上是一个全新的精炼模板整合计划 2021年度训练联盟热身训练赛第四场 H - Rock Paper Scissors(字符串匹配,FF ...

  3. Python编程基础:第三十七节 石头剪刀布游戏Rock, Paper, Scissors Game

    第三十七节 石头剪刀布游戏Rock, Paper, Scissors Game 前言 实践 前言 我们这一节的内容主要是对前边学习内容的一个综合应用,以石头,剪刀,布游戏为例讲解列表.随机数.用户输入 ...

  4. CodeForces - 1426E Rock, Paper, Scissors(最小费用最大流+最大费用最大流)

    题目链接:点击查看 题目大意:A 和 B 在玩石头剪刀布,A 会出 a1 次石头,a2 次剪刀,a3 次布,同理 B 会出 b1 次石头,b2 次剪刀,b3 次布,若对战顺序是可以进行决定的,问 A ...

  5. 计蒜客A1676 Rock Paper Scissors Lizard Spock

    链接 https://nanti.jisuanke.com/t/A1676 题解 每种分开算,比如我先考虑出 s c i s s o r s scissors scissors,把模式串中的所有 S ...

  6. Problem H Rock Paper Scissors,FFT

    题目 题目链接 题意 给出两段石头剪刀布的顺序SSS和T" role="presentation" style="position: relative;&quo ...

  7. Codeforces 437C The Child and Toy(贪心)

    题目连接:Codeforces 437C  The Child and Toy 贪心,每条绳子都是须要割断的,那就先割断最大值相应的那部分周围的绳子. #include <iostream> ...

  8. codeforces#320(div2) D Or Game 贪心

    codeforces#320(div2) D  "Or" Game  贪心 D. "Or" Game time limit per test 2 seconds ...

  9. Rock Paper将为圣地亚哥教士棒球队开发AR游戏

    7月18日青亭网报道,联想.摩托罗拉,以及Rock Paper Reality,将联合圣地亚哥教士棒球队开发一款棒球主题的AR游戏. 很显然,目前高通骁龙Spaces XR开发套件就是基于上述硬件:摩 ...

最新文章

  1. CIKM 2021 | 基于IPCA的多属性分子优化
  2. 业界丨2018,人工智能革命走向风口浪尖
  3. mysql中有哪些数值型函数_mysql数值型函数汇总
  4. Python处理图像五个有趣场景,很实用!
  5. sjms-4 行为型模式
  6. python用pandas读取excel_Python使用pandas读取Excel文件数据和预处理小案例
  7. [.Net线程处理系列]专题五:线程同步——事件构造
  8. 知识图谱的概念、应用与构建
  9. vscode vue解决跨域_在vs code 中如何创建一个自己的 Vue 模板代码
  10. (超简单思路)U - C语言实验——单词统计
  11. python判断一个数是否是质数
  12. UVA10295 POJ2403 ZOJ1902 Hay Points【map】
  13. Java大厂面试100题,你面试时总会用到的!
  14. IIS_设置64位机器上的(IIS6/IIS7)兼容32位程序
  15. 苹果mac笔记本部分按键失灵怎么回事?5连option键即可解决
  16. matplotlib添加字体、字体格式自定义
  17. python 组合优化 回撤最小_【研究】如何用python实现Markowitz投资组合优化
  18. linux下多线程验证数独,6.6.1 数独求解服务器
  19. 是非人生 — 一个菜鸟程序员的5年职场路 第9节
  20. android 带刻度的滑动条_Android实现滑动刻度尺效果

热门文章

  1. 【物理/数学】概念的理解 —— pivot、position
  2. LED —— 发光二极管
  3. sudo echo x **.** 时 base: : Permission denied
  4. matlab 中的内联函数、匿名函数和函数函数
  5. 机器学习基础(四十五)—— 模拟退火(Simulated Annealing)
  6. Trick(十)——any/all 实现
  7. word 的使用(四)—— 对齐与美观(表格)
  8. python能做什么excel-python能做什么,python自学行吗?
  9. python日常能做什么-Python除了做AI、还能干啥?
  10. python培训班靠谱吗-什么样的python培训机构靠谱?