This problem can be easily solved using properties of deque,below is the implementation of the same:::
#include<bits/stdc++.h>
using namespace std;
int main()
{int a;
cin>>a;
while(a--)
{
int q,w;
cin>>q;
deque<int> dq;
for(int i=0;i<q;i++)
{ cin>>w;
dq.push_back(w);
}
int p=-1;
int moves=0,alice=dq.front(),alice_total=0,bob=0,bob_total=0;
alice_total=alice;
dq.pop_front();
while(dq.size()>0)
{
if(p==-1)//bob turn
{ bob=0;
while(bob<=alice&&dq.size()>0)
{
bob+=dq.back();
dq.pop_back();
}
bob_total+=bob;
moves++;
}
else//alice turn
{
alice=0;
while(alice<=bob&&dq.size()>0)
{
alice+=dq.front();
dq.pop_front();
}
alice_total+=alice;
moves++;
}
p=p*-1;
}
cout<<moves+1<<" "<<alice_total<<" "<<bob_total<<endl;
}
return 0;
}