Problem - 1352D - Codeforces
解析:
模拟即可。
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=2e5+5;
int t,n,a[N];
signed main(){scanf("%lld",&t);while(t--){scanf("%lld",&n);for(int i=1;i<=n;i++) scanf("%lld",&a[i]);int sum1=a[1],sum2=0,cnt1=a[1],cnt2=0;int i=2,j=n,p=0,s=1;while(i<=j){if(p){cnt1+=a[i];if(cnt1>cnt2||i==j){sum1+=cnt1;cnt2=0;s++;p=0;}i++;}else{cnt2+=a[j];if(cnt2>cnt1||i==j){sum2+=cnt2;cnt1=0;s++;p=1;}j--;}}printf("%lld %lld %lld\n\n",s,sum1,sum2);}return 0;
}