# PROBLEM LINK:

* Author:* Aman Nautiyal

*Suyash Saxena*

**Tester:***Suyash Saxena*

**Editorialist:**# DIFFICULTY:

SIMPLE

# PREREQUISITES:

Math

# PROBLEM:

Given the number of submissions and the number of correct submissions to a problem during different timestamps in chronological order, verify if the numbers being read make sense when taken in chronological order and can be deemed as correct input. Additionally if the input is correct, using the number of correct submissions and total submissions assign a difficulty level to the problem based on accuracy, i.e., \frac{\text{no. of correct submissions}}{\text{no. of total submissions }}*100

- accuracy < 25% \rightarrow difficulty = hard
- 50% > accuracy \geq 25% \rightarrow difficulty = medium
- 75% > accuracy \geq 50% \rightarrow difficulty = easy
- accuracy \geq 75% \rightarrow difficulty = cakewalk

# QUICK EXPLANATION:

Keep track of the immediate previous input and when new input is received, compare it with older data. If no. of previous total submissions or no. of previous correct submissions is higher than the current total submissions or current correct submissions respectively, then input is incorrect. Additionally if the increase in total submissions is less than increase in correct submissions, then also the input is incorrect. If the inputs pass the previous tests, then we can simply assign the difficulty level to them.

# EXPLANATION:

If we closely inspect the problem we can determine all the cases when an input can be wrong or deemed as incorrect, which are

- No. of current total submissions is less than the last number of total submissions.
- No. of current correct submissions is less than the last number of correct submissions.
- No. of correct submissions is more than the number of total submissions.
- Increase in the number of correct submissions is more than the increase in number of total submissions.

We need to create a compound ‘if’ statement which will compare the current input with the previous and check if:

- No. of previous total submissions is less than no. of current total submissions. (For case 1)

or - No. of previous correct submissions is less than no. of current correct submissions. (For case 2)

or - Increase in the number of correct submissions is more than the increase in total submissions. (For cases 3 & 4)

If any of these conditions is true, we simply print **no**, otherwise we print **yes** followed by the difficulty level which can be easily calculated using a simple if-else-if ladder.

# SOLUTIONS:

## Editorialist's Solution

```
#include <bits/stdc++.h>
#define ull unsigned long long int
#define ll long long int
#define incr(n) for (ll i = 0; i < n; ++i)
#define decr(n) for (ll i = n - 1; i >= 0; --i)
#define rep(x, s, n) for (ll x = s; x < n; ++x)
using namespace std;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
//freopen("output.txt","w",stdout);
#endif
ll t;
cin >> t;
while (t--) {
ll n;
cin >> n;
int prev_s = 0, prev_c = 0;
bool correct = true;
for (int i = 0; i < n; i++)
{
int s, c;
cin >> s >> c;
if (prev_s > s || prev_c > c || (c - prev_c > s - prev_s))
{
correct = false;
cout << "NO" << endl;
break;
}
prev_s = s;
prev_c = c;
}
if(correct)
{
cout << "YES ";
double accuracy = ((double)prev_c / (double)prev_s) * 100;
if (accuracy < 25)
cout << "HARD" << endl;
else if (accuracy < 50)
cout << "MEDIUM" << endl;
else if (accuracy < 75)
cout << "EASY" << endl;
else
cout << "CAKEWALK" << endl;
}
}
return 0;
}
```