Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- #include <ext/pb_ds/assoc_container.hpp>
- using namespace __gnu_pbds;
- using namespace std;
- #define ff first
- #define ss second
- #define int long long
- #define pb push_back
- #define mp make_pair
- #define pii pair<int,int>
- #define vi vector<int>
- #define mii map<int,int>
- #define pqb priority_queue<int>
- #define pqs priority_queue<int,vi,greater<int> >
- #define setbits(x) __builtin_popcountll(x)
- #define zrobits(x) __builtin_ctzll(x)
- #define mod 1000000007
- #define inf 1e18
- #define ps(x,y) fixed<<setprecision(y)<<x
- #define mk(arr,n,type) type *arr=new type[n];
- #define w(x) int x; cin>>x; while(x--)
- mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
- #define fastio ios_base::sync_with_stdio(0); cin.tie(0);
- int32_t main()
- {
- w(t)
- {
- int n,cnt=1,ans,sum=0;
- string temp="Poonguzhali";
- cin>>n;
- vi p,v;
- vi c(n);
- for(int i=0;i<n;i++) {cin>>c[i];sum+=c[i];}
- for(int i=n-2;i>=0;i--){
- if(cnt==1 ) p.pb(c[i]);
- else {v.pb(c[i]);ans+=c[i];}
- cnt=1-cnt;
- }
- // for(auto x:p) cout<<x<<" ";cout<<endl;
- // for(auto x:v) cout<<x<<" ";cout<<endl;
- if(n==1 ||n==2)
- {
- if(n==1) ans=0;
- if(n==2){
- if(c[1]>c[0]) ans=c[1];
- else if(c[1]==c[0]) temp="Tie";
- else {temp="Vanthiyathevan";ans=c[0];}
- }
- }
- else{
- for(int i=1;i<v.size();i++) v[i]+=v[i-1];
- for(int i=p.size()-2;i>=0;i--) p[i]+=p[i+1];
- ans=max(p.back(),v.back());
- for(int i=0;i<p.size();i++){
- int l=0,r=0;
- l=p[i];
- if(i-1>=0 && i-1<v.size()) r=v[i-1];
- ans=max(ans,l+r);
- }
- if(ans==sum-ans) temp="Tie";
- else if(ans>sum-ans) temp="Vanthiyathevan";
- }
- if(temp=="Tie") cout<<temp<<"\n";
- else
- {
- cout<<temp<<" "<<ans<<" "<<sum-ans<<"\n";
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment