Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- #define ll long long
- #define fast()(ios_base::sync_with_stdio(0),cin.tie(NULL));
- int main()
- {
- ll t;
- cin>>t;
- while(t--)
- {
- ll n;
- cin>>n;
- ll ara[n+1];
- for(ll i=0; i<n;i++)cin>> ara[i];
- ll mov=1,alice=ara[0],bob=0,suma=ara[0],sumb=0;
- ll i=1,j=n-1;
- bool tog=true;
- while(i<=j)
- {
- if(alice<bob)
- {
- suma+=ara[i];
- alice+=ara[i];
- i++;
- if(!tog)mov++;
- tog=true;
- if(alice>bob)bob=0;
- }
- else if(bob<alice)
- {
- sumb+=ara[j];
- bob+=ara[j];
- j--;
- if(tog)mov++;
- tog=false;
- if(bob>alice)alice=0;
- }
- else
- {
- if(tog)
- {
- suma+=ara[i];
- alice+=ara[i];
- i++;
- bob=0;
- }
- else
- {
- sumb+=ara[j];
- bob+=ara[j];
- j--;
- alice=0;
- }
- }
- }
- cout<<mov<<" "<<suma<<" "<<sumb<<endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement