☰
B. Valerii Against Everyone
2026/9/28 21:16:37 网站建设 项目流程

time limit per test

1 second

memory limit per test

256 megabytes

You're given an array b of length n. Let's define another array a, also of length n, for which ai=2bi (1≤i≤n).

Valerii says that every two non-intersecting subarrays of a have different sums of elements. You want to determine if he is wrong. More formally, you need to determine if there exist four integers l1,r1,l2,r2 that satisfy the following conditions:

  • 1≤l1≤r1<l2≤r2≤n;
  • al1+al1+1+…+ar1−1+ar1=al2+al2+1+…+ar2−1+ar2.

If such four integers exist, you will prove Valerii wrong. Do they exist?

An array c is a subarray of an array d if c can be obtained from d by deletion of several (possibly, zero or all) elements from the beginning and several (possibly, zero or all) elements from the end.

Input

Each test contains multiple test cases. The first line contains the number of test cases t (1≤t≤100). Description of the test cases follows.

The first line of every test case contains a single integer n (2≤n≤1000).

The second line of every test case contains n integers b1,b2,…,bn (0≤bi≤109).

Output

For every test case, if there exist two non-intersecting subarrays in a that have the same sum, output YES on a separate line. Otherwise, output NO on a separate line.

Also, note that each letter can be in any case.

Example

Input

Copy

2 6 4 3 0 1 2 0 2 2 5

Output

Copy

YES NO

Note

In the first case, a=[16,8,1,2,4,1]. Choosing l1=1, r1=1, l2=2 and r2=6 works because 16=(8+1+2+4+1).

In the second case, you can verify that there is no way to select to such subarrays.

解题说明:此题是一道模拟题,找规律能发现,如果 b中有两个相等的值,,那么 ai=aj​。取子数组 [i,i]和 [j,j]两个单元素子数组,它们不相交,且和都等于 ai=aj,相等。因此只要 bb 中有重复元素,答案就是 YES。可以用set集合来判断。

#include <iostream> #include<vector> #include<algorithm> #include<set> using namespace std; int main() { int t; cin >> t; while (t--) { set<int> s; int n, x; cin >> n; for (int i = 0; i < n; i++) { cin >> x; s.insert(x); } if (s.size() == n) { cout << "NO\n"; } else { cout << "YES\n"; } } return 0; }

需要专业的网站建设服务?

联系我们获取免费的网站建设咨询和方案报价,让我们帮助您实现业务目标

立即咨询