codeforces-scrape

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

1371C.md (3251B)


      1 Source: https://codeforces.com/problemset/problem/1371/C
      2 
      3 C. A Cookie for You
      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 Anna is a girl so brave that she is loved by everyone in the city and citizens love her cookies. She is planning to hold a party with cookies. Now she has $a$ vanilla cookies and $b$ chocolate cookies for the party.
     22 
     23 She invited $n$ guests of the first type and $m$ guests of the second type to the party. They will come to the party in some order. After coming to the party, each guest will choose the type of cookie (vanilla or chocolate) to eat. There is a difference in the way how they choose that type:
     24 
     25 If there are $v$ vanilla cookies and $c$ chocolate cookies at the moment, when the guest comes, then
     26 
     27 * if the guest of the first type: if $v \gt c$ the guest selects a vanilla cookie. Otherwise, the guest selects a chocolate cookie.
     28 * if the guest of the second type: if $v \gt c$ the guest selects a chocolate cookie. Otherwise, the guest selects a vanilla cookie.
     29 
     30 After that:
     31 
     32 * If there is at least one cookie of the selected type, the guest eats one.
     33 * Otherwise (there are no cookies of the selected type), the guest gets angry and returns to home.
     34 
     35 Anna wants to know if there exists some order of guests, such that no one guest gets angry. Your task is to answer her question.
     36 
     37 Input
     38 
     39 The input consists of multiple test cases. The first line contains a single integer $t$ ($1 \le t \le 1000$) — the number of test cases. Next $t$ lines contain descriptions of test cases.
     40 
     41 For each test case, the only line contains four integers $a$, $b$, $n$, $m$ ($0 \le a,b,n,m \le 10^{18}, n+m \neq 0$).
     42 
     43 Output
     44 
     45 For each test case, print the answer in one line. If there exists at least one valid order, print "Yes". Otherwise, print "No".
     46 
     47 You can print each letter in any case (upper or lower).
     48 
     49 Example
     50 
     51 Input
     52 
     53 ```
     54 6
     55 2 2 1 2
     56 0 100 0 1
     57 12 13 25 1
     58 27 83 14 25
     59 0 0 1 0
     60 1000000000000000000 1000000000000000000 1000000000000000000 1000000000000000000
     61 ```
     62 
     63 Output
     64 
     65 ```
     66 Yes
     67 No
     68 No
     69 Yes
     70 No
     71 Yes
     72 ```
     73 
     74 Note
     75 
     76 In the first test case, let's consider the order $\{1, 2, 2\}$ of types of guests. Then:
     77 
     78 * The first guest eats a chocolate cookie. After that, there are $2$ vanilla cookies and $1$ chocolate cookie.
     79 * The second guest eats a chocolate cookie. After that, there are $2$ vanilla cookies and $0$ chocolate cookies.
     80 * The last guest selects a chocolate cookie, but there are no chocolate cookies. So, the guest gets angry.
     81 
     82 So, this order can't be chosen by Anna.
     83 
     84 Let's consider the order $\{2, 2, 1\}$ of types of guests. Then:
     85 
     86 * The first guest eats a vanilla cookie. After that, there is $1$ vanilla cookie and $2$ chocolate cookies.
     87 * The second guest eats a vanilla cookie. After that, there are $0$ vanilla cookies and $2$ chocolate cookies.
     88 * The last guest eats a chocolate cookie. After that, there are $0$ vanilla cookies and $1$ chocolate cookie.
     89 
     90 So, the answer to this test case is "Yes".
     91 
     92 In the fifth test case, it is illustrated, that the number of cookies ($a + b$) can be equal to zero, but the number of guests ($n + m$) can't be equal to zero.
     93 
     94 In the sixth test case, be careful about the overflow of $32$-bit integer type.