2 solutions

  • -1
    @ 2026-5-22 18:39:55
    #include<bits/stdc++.h>
    using namespace std;
    const int N=10010;
    int a[N];
    int main()
    {
    	int t;
    	cin>>t;
    	while(t--)
    	{
    		int n;
    		cin>>n;
    		for(int i=1;i<=n;i++)
    		{
    			cin>>a[i];
    		}
    		bool st=false;
    		for(int i=1;i+1<=n;i++)
    		{
    			int l=0;
    			for(int j=1;j<=i;j++)
    			{
    				l+=a[j];
    			}
    			int r=0;
    			for(int j=i+1;j<=n;j++)
    			{
    				r+=a[j];
    			}
    			if(l==r)
    			{
    				st=true;
    			}
    		}
    		if(st)
    		{
    			cout<<"Yes"<<endl;
    		}
    		else
    		{
    			cout<<"No"<<endl;
    		}
    	}
    	return 0;
    }
    
    

    Information

    ID
    2197
    Time
    1000ms
    Memory
    256MiB
    Difficulty
    3
    Tags
    # Submissions
    35
    Accepted
    8
    Uploaded By