#include <bits/stdc++.h>
using namespace std;
int main()
{
long long S, Q;
cin >> S >> Q;
for (long long i = 0; i < Q; i++)
{
long long PowH, PowG, BlockH, BlockG;
cin >> PowH >> BlockG >> PowG >> BlockH;
long long A = max(0LL, PowG - S * BlockG), B = max(0LL, PowH - S * BlockH);
long long turn = 1;
while (PowH > 0 && PowG > 0)
{
if (turn)
{
if (A >= S || B >= S || BlockH == 0)
{
A = max(0LL, A - B);
PowG -= B;
}
else
{
BlockH--;
B = max(0LL, PowH - S * BlockH);
}
}
else
{
if (A >= S || B >= S || BlockG == 0)
{
B = max(0LL, B - A);
PowH -= A;
}
else
{
BlockG--;
A = max(0LL, PowG - S * BlockG);
}
}
turn = 1 - turn;
}
if (PowG < 1)
cout << "YES" << '\n';
else
cout << "NO" << '\n';
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |