-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
31 lines (29 loc) · 795 Bytes
/
Program.cs
File metadata and controls
31 lines (29 loc) · 795 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
using System;
using System.Linq;
namespace SherlockAndArray
{
class Program
{
static void Main(string[] args)
{
int t = Convert.ToInt32(Console.ReadLine());
for(int i = 0; i < t; i++)
{
int[] arr = new int[Convert.ToInt32(Console.ReadLine())];
arr = Array.ConvertAll(Console.ReadLine().Split(' '), Int32.Parse);
Console.WriteLine(solve(arr) ? "YES" : "NO");
}
}
static bool solve(int[] A)
{
int LS = 0, RS = A.Sum();
for(int i = 0; i < A.Length; i++)
{
RS -= A[i];
if (LS == RS) return true;
LS += A[i];
}
return false;
}
}
}