Untitled

mail@pastecode.io avatar
unknown
c_cpp
2 months ago
716 B
16
Indexable
Never
#include <bits/stdc++.h>

using namespace std;

int main()
{
   int t;
   cin>>t;
   while(t--)
   {
     int n;
     cin>>n;
     int a[n];
     unordered_map<long long,int> k;
     long long int c=0;
     long long int d=0;
     int f=0;
     for(int i=0;i<n;i++)
     {
         cin>>a[i];
     }
      for(int i=0;i<n;i++)
     {
         if(i%2==0){
             c+=a[i];
        
     }
     else
     {
         d+=a[i];
         
     }
      long long diff=c-d;
      k[diff]++;
      if(k[diff]>1 || diff==0)
      {
          f=1;
          break;
      }
     }
     
    if(f==1)
    cout<<"yes"<<endl;
    else
    cout<<"no"<<endl;
   }

    return 0;
}
Leave a Comment