夏日甜点
第一眼看,怎么这么难,看完以后,好简单啊。
思路
因为划分每一段的价值都等于该段甜点风味值的和,总评价就是所有元甜点风味值之和:
证明
我们可以设区间长度为
可知,每一项的结果均不超过
所以就可以得出:
即
综上可知,答案与
AC Code
#include<bits/stdc++.h>
#define AC 0
using namespace std;
const int N=1e5+10;
const int M=1e4+10;
const int K=1e3+10;
const int MOD=1e9+7;
const int INF=-1e9;
typedef long long ll;
typedef pair<int,int> PII;
int a[N];
signed main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n,k;
cin>>n>>k;
long long sum=0;
for(int i=1;i<=n;i++) cin>>a[i],sum+=a[i];
cout<<sum<<endl;
return AC;
}