codeforces-scrape

Codeforces scraped problems and editorials
git clone git://git.laack.co/codeforces-scrape.git
Log | Files | Refs | README

1438B.md (1902B)


      1 Source: https://codeforces.com/problemset/problem/1438/B
      2 
      3 B. Valerii Against Everyone
      4 
      5 time limit per test
      6 
      7 1 second
      8 
      9 memory limit per test
     10 
     11 256 megabytes
     12 
     13 input
     14 
     15 standard input
     16 
     17 output
     18 
     19 standard output
     20 
     21 You're given an array $b$ of length $n$. Let's define another array $a$, also of length $n$, for which $a_i = 2^{b_i}$ ($1 \leq i \leq n$).
     22 
     23 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 $l_1,r_1,l_2,r_2$ that satisfy the following conditions:
     24 
     25 * $1 \leq l_1 \leq r_1 \lt l_2 \leq r_2 \leq n$;
     26 * $a_{l_1}+a_{l_1+1}+\ldots+a_{r_1-1}+a_{r_1} = a_{l_2}+a_{l_2+1}+\ldots+a_{r_2-1}+a_{r_2}$.
     27 
     28 If such four integers exist, you will prove Valerii wrong. Do they exist?
     29 
     30 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.
     31 
     32 Input
     33 
     34 Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \le t \le 100$). Description of the test cases follows.
     35 
     36 The first line of every test case contains a single integer $n$ ($2 \le n \le 1000$).
     37 
     38 The second line of every test case contains $n$ integers $b_1,b_2,\ldots,b_n$ ($0 \le b_i \le 10^9$).
     39 
     40 Output
     41 
     42 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.
     43 
     44 Also, note that each letter can be in any case.
     45 
     46 Example
     47 
     48 Input
     49 
     50 ```
     51 2
     52 6
     53 4 3 0 1 2 0
     54 2
     55 2 5
     56 ```
     57 
     58 Output
     59 
     60 ```
     61 YES
     62 NO
     63 ```
     64 
     65 Note
     66 
     67 In the first case, $a = [16,8,1,2,4,1]$. Choosing $l_1 = 1$, $r_1 = 1$, $l_2 = 2$ and $r_2 = 6$ works because $16 = (8+1+2+4+1)$.
     68 
     69 In the second case, you can verify that there is no way to select to such subarrays.