标签:
#include<cstdio>
#include<algorithm>
using namespace std;
const int maxn = 1E4 + 10;
long long a[maxn],b[maxn];
int main(){
int t;
scanf("%d",&t);
while(t--){
int n,tmp;
long long s[2] = {0};
scanf("%d",&n);
if(!(n&1)){
for(int i = 0; i < n ; ++i){
scanf("%d",&tmp);
s[i&1] += tmp;
}
printf("%I64d\n",max(s[0],s[1]));
}else {
a[0] = b[0] = 0;
for(int i = 1 ; i <= n; ++i){
scanf("%d",&tmp);
if(i & 1){
a[i] = a[i - 1] + tmp;
b[i] = b[i - 1];
}else {
a[i] = a[i - 1];
b[i] = b[i - 1] + tmp;
}
}
long long ans = -1E4 * 1E9;
for(int i = 0 ; i < n ; ++i){
if(i & 1){
ans = max(ans , a[i] + b[n] - b[i]);
}
else{
ans = max(ans , b[i] + a[n] - a[i]);
}
}
printf("%I64d\n",ans);
}
}
return 0;
}
[2016-04-17][Gym][100947][C][Rotate It !!]
标签:
原文地址:http://www.cnblogs.com/qhy285571052/p/edce65cb92ca410785ded2af02425107.html