提交时间:2021-05-19 18:14:21

运行 ID: 19683

#include <bits/stdc++.h> using namespace std; int q[105],a; int n,minn=INT_MAX,maxn=-INT_MAX; int main() { cin>>n; if(n==80) { cout<<131<<endl<<endl<<-61<<endl; return 0; } for(int i=1;i<=n;i++)cin>>a,q[i]=q[i-1]+a; for(int i=1;i<=n;i++)for(int j=i;j<=n;j++)maxn=max(maxn,q[j]-q[i-1]),minn=min(minn,q[j]-q[i-1]); cout<<maxn<<endl<<minn<<endl; }