codeforces-scrape

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

1363A.md (1569B)


      1 Source: https://codeforces.com/problemset/problem/1363/A
      2 
      3 A. Odd Selection
      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 Shubham has an array $a$ of size $n$, and wants to select exactly $x$ elements from it, such that their sum is odd. These elements do not have to be consecutive. The elements of the array are not guaranteed to be distinct.
     22 
     23 Tell him whether he can do so.
     24 
     25 Input
     26 
     27 The first line of the input contains a single integer $t$ $(1\le t \le 100)$ — the number of test cases. The description of the test cases follows.
     28 
     29 The first line of each test case contains two integers $n$ and $x$ $(1 \le x \le n \le 1000)$ — the length of the array and the number of elements you need to choose.
     30 
     31 The next line of each test case contains $n$ integers $a_1, a_2, \dots, a_n$ $(1 \le a_i \le 1000)$ — elements of the array.
     32 
     33 Output
     34 
     35 For each test case, print "Yes" or "No" depending on whether it is possible to choose $x$ elements such that their sum is odd.
     36 
     37 You may print every letter in any case you want.
     38 
     39 Example
     40 
     41 Input
     42 
     43 ```
     44 5
     45 1 1
     46 999
     47 1 1
     48 1000
     49 2 1
     50 51 50
     51 2 2
     52 51 50
     53 3 3
     54 101 102 103
     55 ```
     56 
     57 Output
     58 
     59 ```
     60 Yes
     61 No
     62 Yes
     63 Yes
     64 No
     65 ```
     66 
     67 Note
     68 
     69 For $1$st case: We must select element $999$, and the sum is odd.
     70 
     71 For $2$nd case: We must select element $1000$, so overall sum is not odd.
     72 
     73 For $3$rd case: We can select element $51$.
     74 
     75 For $4$th case: We must select both elements $50$ and $51$  — so overall sum is odd.
     76 
     77 For $5$th case: We must select all elements  — but overall sum is not odd.