提交时间:2021-05-28 22:11:22
运行 ID: 20073
#include<bits/stdc++.h> using namespace std; int n,a[101],num,maxs,mins,maxn,minn; int main(){ cin>>n; for(int i=1;i<=n;i++){ cin>>a[i]; num+=a[i]; if(i==1){ maxn=minn=a[i]; } else{ maxn=max(num-mins,maxn); minn=min(num-maxs,minn); maxs=max(maxs,num); mins=min(mins,num); } } cout<<maxn<<endl<<minn; return 0; }