Type: Default File IO: max 1000ms 256MiB

MAX

You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.

题目背景

一场比赛需要一个送分题。

题目描述

给定初始值 ss 和一个极限值 maxmax 和一个长度为 nn 的序列 A1,A2,A3...AnA_1,A_2,A_3...A_n ,你需要依次执行操作。记当前值为 nownow ((初始为s)s) , 对于第 ii 次操作,你需要将当前值 nownow 转变为 now+Ainow+A_i 或者 nowAinow-A_i 。对于所有时刻,都需要保证 nownow \le maxmax 并且 nownow 0 \ge 0 。我们希望经过 nn 次操作后当前值 nownow 的值最大,你需要输出这个最大值。如果无论如何也无法使 0nowmax0 \le now \le max ,输出 1-1

输入格式

输入格式共两行。

第一行三个整数 n,s,maxn,s,max

第二行为序列AAA1,A2,A3AnA_1,A_2,A_3\dots A_n

输出格式

输出一行一个整数 nownow

3 5 10
5 3 7
10

数据范围

对于 30%30\% 的数据:n=1n=1

对于 60%60\% 的数据:n50n\le50

对于 100%100\% 的数据:n1000,1max1000,0smaxn\le1000,1 \le max \le 1000,0 \le s \le max

0225

Not Attended
Status
Done
Rule
IOI
Problem
4
Start at
2026-2-25 8:00
End at
2026-2-25 11:39
Duration
3.7 hour(s)
Host
Partic.
41