CF1197D.Yet Another Subarray Problem
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are given an array a1,a2,…,an and two integers m and k .
You can choose some subarray al,al+1,…,ar−1,ar .
The cost of subarray al,al+1,…,ar−1,ar is equal to i=l∑rai−k⌈mr−l+1⌉ , where ⌈x⌉ is the least integer greater than or equal to x .
The cost of empty subarray is equal to zero.
For example, if m=3 , k=10 and a=[2,−4,15,−3,4,8,3] , then the cost of some subarrays are:
- a3…a3:15−k⌈31⌉=15−10=5 ;
- a3…a4:(15−3)−k⌈32⌉=12−10=2 ;
- a3…a5:(15−3+4)−k⌈33⌉=16−10=6 ;
- a3…a6:(15−3+4+8)−k⌈34⌉=24−20=4 ;
- a3…a7:(15−3+4+8+3)−k⌈35⌉=27−20=7 .
Your task is to find the maximum cost of some subarray (possibly empty) of array a .
输入格式
The first line contains three integers n , m , and k ( 1≤n≤3⋅105,1≤m≤10,1≤k≤109 ).
The second line contains n integers a1,a2,…,an ( −109≤ai≤109 ).
输出格式
Print the maximum cost of some subarray of array a .
输入输出样例
输入#1
7 3 10 2 -4 15 -3 4 8 3
输出#1
7
输入#2
5 2 1000 -13 -4 -9 -20 -11
输出#2
0