提交时间:2021-05-28 22:13:35
运行 ID: 20075
#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]; maxs=max(maxs,num); mins=min(mins,num); } 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; }