Problem - C - Codeforces
思路:通过题意能够知道如果移除i,那么i-1与i+1会合成一个新的,同时后面的往前移动两个单位,并且我们发现可以让1 3 5 7 ... 2*n-1合成一个数,让2 4 6 8 ... 2*n合成一个数,同时我们还发现了奇数与偶数位置最后一定不会合成到同一位置,那么我们就只需要统计奇数能够合成的最大值,偶数能够合成的最大值即可
// Problem: C. Particles
// Contest: Codeforces - Codeforces Round 884 (Div. 1 + Div. 2)
// URL: https://codeforces.com/contest/1844/problem/C
// Memory Limit: 256 MB
// Time Limit: 1000 ms
#include<iostream>
#include<cstring>
#include<string>
#include<sstream>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<vector>
#include<set>
#include<unordered_map>
#include<ctime>
#include<cstdlib>
#define fi first
#define se second
#define i128 __int128
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int,int> PII;
typedef pair<int,pair<int,int> > PIII;
const double eps=1e-7;
const int N=5e5+7 ,M=5e5+7, INF=0x3f3f3f3f,mod=1e9+7,mod1=998244353;
const long long int llINF=0x3f3f3f3f3f3f3f3f;
inline ll read() {ll x=0,f=1;char c=getchar();while(c<'0'||c>'9') {if(c=='-') f=-1;c=getchar();}
while(c>='0'&&c<='9') {x=(ll)x*10+c-'0';c=getchar();} return x*f;}
inline void write(ll x) {if(x < 0) {putchar('-'); x = -x;}if(x >= 10) write(x / 10);putchar(x % 10 + '0');}
inline void write(ll x,char ch) {write(x);putchar(ch);}
void stin() {freopen("in_put.txt","r",stdin);freopen("my_out_put.txt","w",stdout);}
bool cmp0(int a,int b) {return a>b;}
template<typename T> T gcd(T a,T b) {return b==0?a:gcd(b,a%b);}
template<typename T> T lcm(T a,T b) {return a*b/gcd(a,b);}
void hack() {printf("\n----------------------------------\n");}
int T,hackT;
int n,m,k;
int w[N];
void solve() {
n=read();
for(int i=1;i<=n;i++) w[i]=read();
int res=-2e9;
for(int i=1;i<=n;i++) res=max(res,w[i]);
if(res<0) {
printf("%d\n",res);
return ;
}
ll ansa=0,ansb=0;
for(int i=1;i<=n;i+=2) {
if(w[i]>0) ansa+=w[i];
}
for(int i=2;i<=n;i+=2) {
if(w[i]>0) ansb+=w[i];
}
write(max(ansa,ansb),'\n');
}
int main() {
// init();
// stin();
scanf("%d",&T);
// T=1;
while(T--) hackT++,solve();
return 0;
}