반응형

 

#include<stdio.h>


int main()
{
	int arr[100000], t, n;
	int c, z;
	long long x1, x2;
	long long y_sum;
	bool check = true;
	scanf("%d", &t);

	for (int i = 0; i < t; i++)
	{
		c = 0;
		z = 0;
		x1 = 0;
		x2 = 0;
		y_sum = 0;
		scanf("%d", &n);
		check = true;

		for (int j = 0; j < n; j++)
		{
			scanf("%d", &arr[j]);
			y_sum += arr[j];

		}

		x1 = arr[0];
		x2 = arr[n - 1];

		if (x1 <= 0 || x2 <= 0)
		{
			check = false;
		}

		for (int j = 1; j < n; j++)
		{

			x1 = x1 + arr[j];
			x2 = x2 + arr[n - 1 - j];

			if (x1 <= 0 || x2 <= 0)
			{
				check = false;
				break;
			}

		}

		if (check == false)
		{
			printf("NO\n");
		}
		else
		{
			printf("YES\n");
		}


	}


	return 0;
}

 

 

https://codeforces.com/contest/1285/problem/B

 

Problem - B - Codeforces

 

codeforces.com

 

반응형

+ Recent posts