打卡信奥刷题(100)用Scratch图形化工具信奥P3078 [USACO13MAR] Poker Hands S

[USACO13MAR] Poker Hands S

题面翻译

Bessie 有 n n n 堆牌,每堆牌有 a i a_i ai 张。她一次可以将第 i i i 堆到第 j j j 堆里打一张出去,求打完 n n n 堆牌最少的次数。

对于 100 % 100\% 100% 的数据, 1 ≤ n ≤ 1 0 5 , 0 ≤ a i ≤ 1 0 5 1\le n\le10^5,0\le a_i\le10^5 1n105,0ai105

题目描述

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 a_i cards of rank i (0 <= a_i <= 100000). Help her find the minimum number of hands she must play to get rid of all her cards.

输入格式

* Line 1: The integer N.

* Lines 2…1+N: Line i+1 contains the value of a_i.

输出格式

* 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.

Scratch实现

在这里插入图片描述

后续

接下来我会不断用scratch来实现信奥比赛中的算法题、Scratch考级编程题实现、白名单赛事考题实现,感兴趣的请关注,我后续将继续分享相关内容

  • 28
    点赞
  • 17
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值