增减序列
code
#include<iostream>
#include<algorithm>
using namespace std;
using ll=long long;
const int N=110000;
ll n,m,i,j,p,q,a[N];
//p为b序列中正数之和,而q为b序列中负数之和
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
cin>>n;
for(i=1;i<=n;++i){
cin>>a[i];
}
for(i=2;i<=n;++i){
ll c =a[i]-a[i-1];
if(0<c){
p+=c;
}else{
q-=c;
}
}
ll ans1=max(q,p),ans2=abs(p-q)+1;
cout<<ans1<<'\n'<<ans2;
return 0;
}