CF1915E.Romantic Glasses

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Iulia has nn glasses arranged in a line. The ii -th glass has aia_i units of juice in it. Iulia drinks only from odd-numbered glasses, while her date drinks only from even-numbered glasses.

To impress her date, Iulia wants to find a contiguous subarray of these glasses such that both Iulia and her date will have the same amount of juice in total if only the glasses in this subarray are considered. Please help her to do that.

More formally, find out if there exists two indices ll , rr such that 1lrn1 \leq l \leq r \leq n , and al+al+2+al+4++ar=al+1+al+3++ar1a_l + a_{l + 2} + a_{l + 4} + \dots + a_{r} = a_{l + 1} + a_{l + 3} + \dots + a_{r-1} if ll and rr have the same parity and al+al+2+al+4++ar1=al+1+al+3++ara_l + a_{l + 2} + a_{l + 4} + \dots + a_{r - 1} = a_{l + 1} + a_{l + 3} + \dots + a_{r} otherwise.

输入格式

The first line contains a single integer tt ( 1t1041 \leq t \leq 10^4 ) — the number of test cases.

The first line of each test case contains a single integer nn ( 1n21051 \leq n \leq 2 \cdot 10^5 ) — the total number of glasses.

The second line of each test case contains nn integers a1,,ana_1, \ldots, a_n ( 1ai1091 \leq a_i \leq 10^9 ) — the amount of juice in each glass.

The sum of nn over all test cases does not exceed 21052 \cdot 10^5 .

输出格式

For each test case, output "YES" if there exists a subarray satisfying the condition, and "NO" otherwise.

You can output the answer in any case (for example, the strings "yEs", "yes", "Yes" and "YES" will be recognized as a positive answer).

输入输出样例

  • 输入#1

    6
    3
    1 3 2
    6
    1 1 1 1 1 1
    10
    1 6 9 8 55 3 14 2 7 2
    8
    1 2 11 4 1 5 1 2
    6
    2 6 1 5 7 8
    9
    2 5 10 4 4 9 6 7 8

    输出#1

    YES
    YES
    NO
    YES
    NO
    YES

说明/提示

In the first test case, Iulia can pick l=1l=1 and r=3r=3 . Then she drinks a1+a3=1+2=3a_1+a_3=1+2=3 units and her date drinks a2=3a_2=3 units of juice.

In the second test case, Iulia can pick l=2l=2 and r=5r=5 . Then she drinks a3+a5=1+1=2a_3+a_5=1+1=2 units and her date drinks a2+a4=1+1=2a_2+a_4=1+1=2 units of juice.

In the third test case no such contiguous subarray works.

In the fourth test case, Iulia can pick l=2l=2 and r=8r=8 . Then she drinks a3+a5+a7=11+1+1=13a_3+a_5+a_7=11+1+1=13 units and her date drinks a2+a4+a6+a8=2+4+5+2=13a_2+a_4+a_6+a_8=2+4+5+2=13 units of juice.

首页