题目:    

           Bowling game

In all asocial teams members ignore each other uniformly, each tight-knit team builds up team spirit their own way. Olya, Egor and Oleg, for example, go play bowling. This story is about how they once decided to take their coach Denis with them for the first time.
Denis is not used to close-knit teams and primitive fun, so he was not in favor of rolling balls. So when it came out that the device counting points near the lane was out of service, he willingly volunteered to perform the counting on a sheet of paper.
"What can be easier?", he thought, "One just needs to write down how many pins the player knocks down in each round. I can think out a couple of problems for the next training session simultaneously".
He has never been so wrong! At the end of the game it appeared that the scoring rules in bowling are not nearly just summing up knocked down pins, moreover, it came out that points cannot be restored from the number of knocked down pins. Oleg, Olya and Egor started to explain the rules of the game talking over each other: strikes, spares, extra roll in the last round... Denis nodded and thought: "Well, a decent problem we have here". He suggested the team calculating minimum and maximum points that can be scored by a player. It’s needless to say that Egor, Oleg and Olya completed this task easily. Now it’s your turn.
Here are the scoring rules in bowling.
  1. The game includes 10 frames (rounds), in each frame one can earn up to 30 points.
  2. In each frame, excluding the last one, the aim is to knock down 10 pins with two rolls. If all pins are knocked down with the first roll, the second roll is omitted.
  3. In the last frame one must initially knock down 10 pins with two rolls as well. If the player succeeds, (s)he gets an extra (third) roll. All available rolls must be used, that is, if all pins have been knocked down and there are rolls left, new 10 pins are put. These 10 pins, if knocked down, do not give extra rolls.
  4. Each knocked down pin gives one point.
  5. If a strike is made (all pins knocked down with one roll) in each frame excluding the last one, the player receives one extra point per each pin knocked down in two subsequent rolls when scoring that frame.
  6. If a spare is made (all pins knocked down with two rolls) in each frame excluding the last one, the player receives one extra point per each pin knocked down in one subsequent roll when scoring that frame.

Input

A single line contains 10 numbers separated by space — number of pins knocked down by the player in each of 10 frames. The first nine can take values from 0 to 10, the last one — from 0 to 30.

Output

Output minimum and maximum points a player could earn based on the game described in the input, separated by space.

Example

input output
10 2 4 8 3 8 1 9 8 7
60 62
2 4 6 8 10 10 8 6 4 2
60 86

思路:被题意hack,总是少看了点东西。

  求最小时均认为第二球得分,0 10 0 10的得分就可以避免分数加倍,

  最大时认为第一球得分,如10 8 0 6 0

  最后特判下第十个得分就可以了

 #include <bits/stdc++.h>

 using namespace std;

 #define MP make_pair
#define PB push_back
typedef long long LL;
typedef pair<int,int> PII;
const double eps=1e-;
const double pi=acos(-1.0);
const int K=1e6+;
const int mod=1e9+; int n,v[],mx,mi; int main(void)
{
for(int i=;i<=;i++)
{
cin>>v[i];
if(i!=) mi+=v[i],mx+=v[i];
if(i!=&&i->&&v[i-]==&&v[i-]==) mx+=v[i];
if(i!=&&i->&&v[i-]==) mx+=v[i];
}
if(v[]<=)
{
mi+=v[],mx+=v[];
if(v[]==v[]&&v[]==)mx+=v[];
if(v[]==)mx+=v[];
}
else
{
if(v[]<=)
{
if(v[]==v[]&&v[]==)mx+=+(v[]-)*;
else if(v[]==) mx+=+(v[]-)*;
else mx+=v[];
}
else
{
if(v[]==v[]&&v[]==)mx+=+v[]-;
else if(v[]==) mx+=+v[]-;
else mx+=v[];
}
if(v[]==)
{
if(v[]<=)
mi+=v[];
else
mi+=+v[];
}
else
mi+=v[];
} cout<<mi<<" "<<mx<<endl;
return ;
}

URAL 2078 Bowling game的更多相关文章

  1. URAL 2078~2089

    URAL 2078~2089 A - Bowling game 题目描述:给出保龄球每一局击倒的球数,按照保龄球的规则,算出总得分的最小值和最大值. solution 首先是最小值:每一局第一球击倒\ ...

  2. URAL 1775 B - Space Bowling 计算几何

    B - Space BowlingTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest/ ...

  3. POJ 3176 Cow Bowling

    Cow Bowling Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 13016   Accepted: 8598 Desc ...

  4. 后缀数组 POJ 3974 Palindrome && URAL 1297 Palindrome

    题目链接 题意:求给定的字符串的最长回文子串 分析:做法是构造一个新的字符串是原字符串+反转后的原字符串(这样方便求两边回文的后缀的最长前缀),即newS = S + '$' + revS,枚举回文串 ...

  5. ural 2071. Juice Cocktails

    2071. Juice Cocktails Time limit: 1.0 secondMemory limit: 64 MB Once n Denchiks come to the bar and ...

  6. ural 2073. Log Files

    2073. Log Files Time limit: 1.0 secondMemory limit: 64 MB Nikolay has decided to become the best pro ...

  7. ural 2070. Interesting Numbers

    2070. Interesting Numbers Time limit: 2.0 secondMemory limit: 64 MB Nikolay and Asya investigate int ...

  8. ural 2069. Hard Rock

    2069. Hard Rock Time limit: 1.0 secondMemory limit: 64 MB Ilya is a frontman of the most famous rock ...

  9. ural 2068. Game of Nuts

    2068. Game of Nuts Time limit: 1.0 secondMemory limit: 64 MB The war for Westeros is still in proces ...

随机推荐

  1. (转)java volatile关键字

    转自:http://www.cnblogs.com/aigongsi/archive/2012/04/01/2429166.html 参考:http://blog.csdn.net/imzoer/ar ...

  2. python3----生成器generator(yield)

    # 列表推导式a = [i for i in range(100) if not(i % 2) and (i % 3)]print(a)# 字典推导式b = {i: i % 2 == 0 for i ...

  3. TypeScript 函数 (五)

    传递给一个函数的参数个数必须与函数期望的参数个数一致. 参数类别: 必须参数 可选参数 :可选参数必须在参数后面. 默认参数 :当用户没有传递这个参数或传递的值是undefined时. 它们叫做有默认 ...

  4. JDBC批量操作性能提升

    JDBC 当使用INSERT INTO....VALUES()语句批量插入的时候,应该使用JDBC的PreparedStatement的批量操作方法,而不是採用一条一条运行的方法. 比如(来源:htt ...

  5. DICOM:docker实现DICOM服务虚拟化

    背景: docker,是一个开源的应用容器引擎,眼下大多应用在部署和运维领域,然而因为全然使用沙箱机制,相互之间能够看做独立的主机,且自身对资源的需求也十分有限.远远低于虚拟机.甚至非常多时候.能够直 ...

  6. Eclipse中JSP页面默认编码修改

    jsp页面默认编码为ISO-8859-1 要修改为UTF-8,步骤如下 选择windon-->preference 在弹出框操作 以后新建jsp页面编码为UTF-8编码

  7. 妈妈再也不用担心我使用git了

    妈妈再也不用担心我使用git了 Dec 29, 2014 git git由于其灵活,速度快,离线工作等特点而倍受青睐,下面一步步来总结下git的基本命令和常用操作. 安装msysgit 下载地址:ms ...

  8. jpa双向一对一关联外键映射

    项目结构: Wife package auth.model; import javax.persistence.CascadeType; import javax.persistence.Column ...

  9. Linux中搭建HTTP服务器

    1.配置IP [root@localhost~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0 DEVICE=eth0 BOOTPROTO=static ...

  10. Java 之单例设计模式

    设计模式: 对问题行之有效的解决方式, 其实它是一种思想. 单例设计模式 解决的问题:就是可以保证一个类在内存中的对象唯一性. 即单个实例. 比如对于A 和 B 两个程序使用同一个配置信息对象时, A ...