打卡信奥刷题(220)用Scratch图形化工具信奥P9123 [普及组][USACO23FEB] Watching Mooloo B

[USACO23FEB] Watching Mooloo B

题面翻译

题目描述

贝茜喜欢看 Mooloo 的演出。因为她是一只忙碌的奶牛,她计划在接下来的 N ( 1 ≤ N ≤ 1 0 5 ) N (1 \le N \le 10^5) N(1N105) 天去看演出。因为 Mooloo 提供了订阅服务,她想要使她花费的钱最少。

Mooloo 有一个有趣的订阅服务系统:若要在此之后的连续 d d d 天看演出,则在订阅时需要花费 d + K ( 1 ≤ K ≤ 1 0 9 ) d+K(1 \le K \le 10^9) d+K(1K109) 个单位价格。你可以随时订阅;若本次订阅已经过期,你可以根据需要订阅多次。基于以上条件,请计算出贝茜最少要花费多少个单位价格,才能完成她的计划。

输入格式

第一行输入两个正整数 N N N K K K

第二行输入 N N N 个正整数,表示在这些天里,贝茜会看 Mooloo 的演出: 1 ≤ d 1 < d 2 < ⋯ < d N ≤ 1 0 14 1 \le d_1<d_2<\cdots<d_N \le 10^{14} 1d1<d2<<dN1014

输出格式

请注意,此问题中可能需要使用 64 位整数数据类型(如 C 或 C++ 中的 long long)。

样例 #1 解释

贝茜在第 7 7 7 天时,购买了 3 3 3 天的订阅,共花费 d + K = 3 + 4 = 7 d+K=3+4=7 d+K=3+4=7 个单位价格。

样例 #2 解释

贝茜在第 1 1 1 天时,购买了 1 1 1 天的订阅,花费 d + K = 1 + 3 = 4 d+K=1+3=4 d+K=1+3=4 个单位价格;在第 10 10 10 天时,也购买了 1 1 1 天的订阅,花费 d + K = 1 + 3 = 4 d+K=1+3=4 d+K=1+3=4 个单位价格。贝茜一共花费了 8 8 8 个单位价格。

translated by liyuanchen2021

题目描述

Bessie likes to watch shows on Mooloo. Because Bessie is a busy cow, she has planned a schedule for the next N ( 1 ≤ N ≤ 1 0 5 ) N (1 \le N \le 10^5) N(1N105) days that she will watch Mooloo. Because Mooloo is a paid subscription service, she now needs to decide how to minimize the amount of money she needs to pay.

Mooloo has an interesting subscription system: it costs d + K ( 1 ≤ K ≤ 1 0 9 ) d+K(1 \le K \le 10^9) d+K(1K109) moonies to subscribe to Mooloo for d consecutive days. You can start a subscription at any time, and you can start a new subscription as many times as you desire if your current subscription expires. Given this, figure out the minimum amount of moonies Bessie needs to pay to fulfill her schedule.

输入格式

The first line contains integers N N N and K K K.

The second line contains N N N integers describing the days Bessie will watch Mooloo: 1 ≤ d 1 < d 2 < ⋯ < d N ≤ 1 0 14 1 \le d_1<d_2< \cdots <d_N \le 10^{14} 1d1<d2<<dN1014.

输出格式

Note that the large size of integers involved in this problem may require the use of 64-bit integer data types (e.g., a “long long” in C/C++).

样例 #1

样例输入 #1

2 4
7 9

样例输出 #1

7

样例 #2

样例输入 #2

2 3
1 10

样例输出 #2

8

提示

Explanation for Sample 1

Bessie buys a three-day subscription on day 7 7 7, spending d + K = 3 + 4 = 7 d+K=3+4=7 d+K=3+4=7 moonies.

Explanation for Sample 2

Bessie first buys a one-day subscription on day 1 1 1, spending d + K = 1 + 3 = 4 d+K=1+3=4 d+K=1+3=4 moonies. Bessie also buys a one-day subscription on day 10 10 10, spending d + K = 1 + 3 = 4 d+K=1+3=4 d+K=1+3=4 moonies. In total, Bessie spends 8 8 8 moonies.

SCORING

  • Inputs 3 − 5 3-5 35: N ≤ 10 N \le 10 N10
  • Inputs 6 − 12 6-12 612: No additional constraints.

Scratch实现

在这里插入图片描述

后续

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

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值