codeforces-scrape

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

1201B.md (1117B)


      1 Source: https://codeforces.com/problemset/problem/1201/B
      2 
      3 B. Zero Array
      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 are given an array $a_1, a_2, \ldots, a_n$.
     22 
     23 In one operation you can choose two elements $a_i$ and $a_j$ ($i \ne j$) and decrease each of them by one.
     24 
     25 You need to check whether it is possible to make all the elements equal to zero or not.
     26 
     27 Input
     28 
     29 The first line contains a single integer $n$ ($2 \le n \le 10^5$) — the size of the array.
     30 
     31 The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 10^9$) — the elements of the array.
     32 
     33 Output
     34 
     35 Print "YES" if it is possible to make all elements zero, otherwise print "NO".
     36 
     37 Examples
     38 
     39 Input
     40 
     41 ```
     42 4
     43 1 1 2 2
     44 ```
     45 
     46 Output
     47 
     48 ```
     49 YES
     50 ```
     51 
     52 Input
     53 
     54 ```
     55 6
     56 1 2 3 4 5 6
     57 ```
     58 
     59 Output
     60 
     61 ```
     62 NO
     63 ```
     64 
     65 Note
     66 
     67 In the first example, you can make all elements equal to zero in $3$ operations:
     68 
     69 * Decrease $a_1$ and $a_2$,
     70 * Decrease $a_3$ and $a_4$,
     71 * Decrease $a_3$ and $a_4$
     72 
     73 In the second example, one can show that it is impossible to make all elements equal to zero.