蒟蒻代码,为什么样例中值域小的两个点对的,值域大的那个错了qwq。
//Code by SweetRain2891!
#include <bits/stdc++.h>
#define int long long
#define inf (int)4557430888798830399
#define oo (int)4485090715960753727
const int mod=1e9+7;
using namespace std;
inline int upd(int &x,int y){
return x=((x%mod+y%mod)%mod+mod)%mod;
}
const int maxn=1e5+10;
int n,a[maxn],dp[maxn][2],ans;
signed main(){
ios::sync_with_stdio(false);
cin.tie(0),cout.tie(0);
#ifndef ONLINE_JUDGE
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
#endif
cin >> n;
for(int i=1;i<=n;i++){
cin >> a[i];
}
upd(dp[1][0],a[1]);
for(int i=2;i<=n;i++){
upd(dp[i][0],dp[i-1][0]+a[i]+(i!=2?dp[i-1][1]+a[i]:0));
upd(dp[i][1],dp[i-1][0]-a[i]);
}
upd(ans,dp[n][0]);
upd(ans,dp[n][1]);
cout << ans << endl;
return 0;
}