CF1915E.Romantic Glasses
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Iulia has n glasses arranged in a line. The i -th glass has ai 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 l , r such that 1≤l≤r≤n , and al+al+2+al+4+⋯+ar=al+1+al+3+⋯+ar−1 if l and r have the same parity and al+al+2+al+4+⋯+ar−1=al+1+al+3+⋯+ar otherwise.
输入格式
The first line contains a single integer t ( 1≤t≤104 ) — the number of test cases.
The first line of each test case contains a single integer n ( 1≤n≤2⋅105 ) — the total number of glasses.
The second line of each test case contains n integers a1,…,an ( 1≤ai≤109 ) — the amount of juice in each glass.
The sum of n over all test cases does not exceed 2⋅105 .
输出格式
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=1 and r=3 . Then she drinks a1+a3=1+2=3 units and her date drinks a2=3 units of juice.
In the second test case, Iulia can pick l=2 and r=5 . Then she drinks a3+a5=1+1=2 units and her date drinks a2+a4=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=2 and r=8 . Then she drinks a3+a5+a7=11+1+1=13 units and her date drinks a2+a4+a6+a8=2+4+5+2=13 units of juice.