打卡信奥刷题(231)用Scratch图形化工具信奥P9367[普及组][ICPC2022 Xi‘an R] Strange Sum

[ICPC2022 Xi’an R] Strange Sum

题目描述

Given a sequence a 1 , a 2 , … , a n a_1, a_2, \ldots, a_n a1,a2,,an.

You are going to select zero or more elements of a a a so that: if you select a i a_i ai, then in any interval of length i i i (formally, in a [ j , j + i − 1 ] a[j, j + i - 1] a[j,j+i1] for any 1 ≤ j ≤ n − i + 1 1 \le j \le n - i + 1 1jni+1) you can select at most 2 2 2 elements.

Calculate the maximal sum of the elements you select.

输入格式

The first line contains an integer n n n ( 2 ≤ n ≤ 1 0 5 2 \leq n \leq 10^5 2n105).

The second line contains n n n integers a 1 , a 2 , … , a n a_1, a_2, \ldots, a_n a1,a2,,an ( − 1 0 9 ≤ a i ≤ 1 0 9 -10^9 \leq a_i \leq 10^9 109ai109).

输出格式

Output a single integer denoting the answer.

样例 #1

样例输入 #1

4
1 4 3 2

样例输出 #1

7

样例 #2

样例输入 #2

3
-10 -10 -10

样例输出 #2

0

提示

Source: The 2022 ICPC Asia Xi’an Regional Contest Problem J.

Author: JohnVictor.

Scratch实现

在这里插入图片描述

后续

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值