#P3078. Poker Hands S
Poker Hands S
Poker Hands S
题面翻译
Bessie 有 堆牌,每堆牌有 张。她一次可以将第 堆到第 堆里打一张出去,求打完 堆牌最少的次数。
对于 的数据,。
题目描述
Bessie and her friends are playing a unique version of poker involving a deck with N (1 <= N <= 100,000) different ranks, conveniently numbered 1..N (a normal deck has N = 13). In this game, there is only one type of hand the cows can play: one may choose a card labeled i and a card labeled j and play one card of every value from i to j. This type of hand is called a "straight".
Bessie's hand currently holds cards of rank i (0 <= <= 100000). Help her find the minimum number of hands she must play to get rid of all her cards.
Bessie和她的朋友们正在玩一种独特的扑克游戏,游戏中的牌组有 N (1 <= N <= 100,000) 个不同的点数,编号为 1 到 N(普通牌组的 N = 13)。在这个游戏中,奶牛只能打出一种牌型:可以选择一张标有 i 的牌和一张标有 j 的牌,然后从 i 到 j 的每个点数都打出一张。这种牌型被称为“顺子”。
贝西手中目前有 张点数为 i 的牌(0 <= <= 100,000)。请帮她算出至少需要打多少手牌才能打出所有牌。
输入格式
* Line 1: The integer N. * 第 1 行:整数 N。
* Lines 2..1+N: Line i+1 contains the value of . * 1+N:第 i+1 行包含 的值
输出格式
* Line 1: The minimum number of straights Bessie must play to get rid of all her cards.
样例 #1
样例输入 #1
5
2
4
1
2
3
样例输出 #1
6
提示
Bessie can play a straight from 1 to 5, a straight from 1 to 2, a straight from 4 to 5, two straights from 2 to 2, and a straight from 5 to 5, for a total of 6 rounds necessary to get rid of all her cards.
大致意思: Bessie可以打出 1 到 5 的顺子、1 到 2 的顺子、4 到 5 的顺子、2 到 2 的两张顺子以及 5 到 5 的顺子,总共需要 6 轮才能打出所有牌。