아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Bring Down the Sky Grading Server

시간 제한4초메모리 제한1024 MB

요약
각 시나리오에서 해커와 의장이 최선을 다해 싸울 때 해커가 서버의 연산력을 0 이하로 떨어뜨릴 수 있는지 판정한다.
난이도

보통10점 중 7점

유형
게임 이론, 수학, 그리디
정답자
아직 제출이 없습니다

문제

Despite running low on oil, the opening ceremony was a great success.* Now, the committee is looking forward to the first competition day. But what’s this? The chairman of the Technical Committee noticed some suspicious network activity—apparently someone is planning to hack the grading server!

The grading server possesses a specific computing power c_Gc\_G which the mysterious hacker will try to reduce to (or below) 00. But the server is also protected by f_Gf\_G firewalls, each of which will reduce the impact of any attack by a fixed amount SS. At each point in time, the hacker can now decide to either

  • take down one of these firewalls, permanently reducing f_Gf\_G by 11 (down to a minimum of 00), or
  • use all of their own computing power c_Hc\_H to attack the server, permanently reducing c_Gc\_G by max⁡c_H−f_G⋅S,0\max \\{c\_H - f\_G \cdot S, 0\\}.

However, the chairman can strike back by either taking down one of the hacker’s f_Hf\_H firewalls or by using the grading server’s computing power to attack the hacker, which will similarly reduce c_Hc\_H by max⁡c_G−f_H⋅S,0\max \\{c\_G - f\_H \cdot S, 0\\}. The chairman and the hacker take turns in their actions, with the hacker going first.

The committee will not know how much computing power and how many firewalls the hacker possesses until the hack has started. At the same time, because the committee might still be able to upgrade the server, its computing power and the number of its firewalls are also still unknown. To plan their defense, the committee therefore needs a program that tells them for QQ different scenarios (c_H,f_H,c_G,f_G)(c\_H , f\_H , c\_G , f\_G ) whether the hacker can bring down the grading server even if the chairman makes optimal decisions.


* At least if one ignores the grand finale with the stage collapsing under the weight of 101710^{17} performers.

입력

The first line of the input contains the integers SS and QQ. Then QQ lines follow, each of which describes a scenario as above and consists of four integers c_Hc\_H f_Hf\_H c_Gc\_G f_Gf\_G: the computing power and number of firewalls of the mysterious hacker and of the grading server, respectively.

출력

Your program should output QQ lines, each of which should consist of a single string: YES if the hacker can reduce the grading server’s computing power to or below 00 in the corresponding scenario (regardless of the chairman’s actions), and NO otherwise.

힌트

Consider the first scenario of the first example:

  • In the beginning, the hacker can attack the grading server, reducing c_Gc\_G by 42−1⋅17=2542 - 1 \cdot 17 = 25 to a new value of 88.
  • Afterwards, the chairman cannot reduce the hacker’s computing power by attacking, so the only sensible thing for him to do is to take down the hacker’s unique firewall.
  • However, the hacker can then reduce the computing power of the grading server to 8−25=−17≤08 - 25 = -17 ≤ 0 by another attack, bringing down the server and ruining the first competition day.

In the second scenario on the other hand:

  • Initially, the only thing the hacker can do is to take down one of the firewalls.
  • Afterwards, the chairman can attack the hacker, reducing their computing power c_Hc\_H to 2626.
  • In the next two rounds, the hacker again can only take down one of the firewalls, while the chairman can attack each time, thus reducing c_Hc\_H below 00 and successfully fighting off the hacker’s attempt.

예제3

  1. 예제 1

    입력
    17 2
    42 1 33 1
    42 1 33 7
    
    예상 출력
    YES
    NO
    
  2. 예제 2

    입력
    1 1
    999999999999 999999999999 999999999999 999999999999
    
    예상 출력
    YES
    
  3. 예제 3

    입력
    2 1
    1000000000000 0 1 1000000000000
    
    예상 출력
    NO