-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathALTARAY.cpp
More file actions
31 lines (31 loc) · 727 Bytes
/
ALTARAY.cpp
File metadata and controls
31 lines (31 loc) · 727 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include<bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin>>t;
while(t--)
{
long int n;
cin>>n;
vector<long long int>a(10005,0);
// vector<long long int>ans(100005,1);
long long int ans=0;
for(long int i=1;i<=n;i++)
cin>>a[i];
for(long int i=2;i<=n;i++)
a[i]+=a[i-1];
for(long int i=1;i<=n-1;i++)
{
for(long int j=i;j<=n-1;j++)
{
for(long int k=j+1;k<=n;k++)
{
for(long int l=k;l<=n;l++)
ans=max(ans,abs(a[j]-a[i-1]-a[l]+a[k-1]));
}
}
}
cout<<ans<<endl;
}
}