ash_sinha

Untitled

Oct 28th, 2022
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.26 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. #include <ext/pb_ds/assoc_container.hpp>
  3. using namespace __gnu_pbds;
  4. using namespace std;
  5.  
  6. #define ff first
  7. #define ss second
  8. #define int long long
  9. #define pb push_back
  10. #define mp make_pair
  11. #define pii pair<int,int>
  12. #define vi vector<int>
  13. #define mii map<int,int>
  14. #define pqb priority_queue<int>
  15. #define pqs priority_queue<int,vi,greater<int> >
  16. #define setbits(x) __builtin_popcountll(x)
  17. #define zrobits(x) __builtin_ctzll(x)
  18. #define mod 1000000007
  19. #define inf 1e18
  20. #define ps(x,y) fixed<<setprecision(y)<<x
  21. #define mk(arr,n,type) type *arr=new type[n];
  22. #define w(x) int x; cin>>x; while(x--)
  23. mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
  24. #define fastio ios_base::sync_with_stdio(0); cin.tie(0);
  25.  
  26.  
  27.  
  28.  
  29.  
  30. int32_t main()
  31. {
  32. w(t)
  33. {
  34. int n,cnt=1,ans,sum=0;
  35. string temp="Poonguzhali";
  36. cin>>n;
  37. vi p,v;
  38. vi c(n);
  39. for(int i=0;i<n;i++) {cin>>c[i];sum+=c[i];}
  40. for(int i=n-2;i>=0;i--){
  41. if(cnt==1 ) p.pb(c[i]);
  42. else {v.pb(c[i]);ans+=c[i];}
  43. cnt=1-cnt;
  44. }
  45.  
  46. // for(auto x:p) cout<<x<<" ";cout<<endl;
  47. // for(auto x:v) cout<<x<<" ";cout<<endl;
  48.  
  49. if(n==1 ||n==2)
  50. {
  51. if(n==1) ans=0;
  52. if(n==2){
  53. if(c[1]>c[0]) ans=c[1];
  54. else if(c[1]==c[0]) temp="Tie";
  55. else {temp="Vanthiyathevan";ans=c[0];}
  56. }
  57. }
  58. else{
  59. for(int i=1;i<v.size();i++) v[i]+=v[i-1];
  60. for(int i=p.size()-2;i>=0;i--) p[i]+=p[i+1];
  61. ans=max(p.back(),v.back());
  62. for(int i=0;i<p.size();i++){
  63. int l=0,r=0;
  64. l=p[i];
  65. if(i-1>=0 && i-1<v.size()) r=v[i-1];
  66. ans=max(ans,l+r);
  67. }
  68. if(ans==sum-ans) temp="Tie";
  69. else if(ans>sum-ans) temp="Vanthiyathevan";
  70. }
  71. if(temp=="Tie") cout<<temp<<"\n";
  72. else
  73. {
  74. cout<<temp<<" "<<ans<<" "<<sum-ans<<"\n";
  75. }
  76.  
  77.  
  78. }
  79. return 0;
  80. }
Advertisement
Add Comment
Please, Sign In to add comment