Posted in: trivia

Difficulty Rating Order codechef solution

Difficulty Rating Order codechef solution

 

CodeCheffers are aware that after a contest, all problems are moved into the platform’s practice section. Based on user submissions during the contest, the system calculates and assigns a difficulty rating to each problem. Ideally, it is recommended that users practice problems in increasing order of difficulty.

Our Chef has some students in his coding class who are practicing problems. Given the difficulty of the problems that the students have solved in order, help the Chef identify if they are solving them in non-decreasing order of difficulty. That is, the students should not solve a problem with difficulty d1d1, and then later a problem with difficulty d2d2, where d1>d2d1>d2.

Output “Yes” if the problems are attempted in non-decreasing order of difficulty rating and “No” if not.

Input Format

Difficulty Rating Order codechef solution

  • The first line of input will contain a single integer TT, denoting the number of test cases. The description of the test cases follows.
  • Each test case consists of 22 lines of input.
    • The first line contains a single integer NN, the number of problems solved by the students
    • The second line contains NN space-separate integers, the difficulty ratings of the problems attempted by the students in order.

Output Format

  • For each test case, output in a new line “Yes” if the problems are attempted in non-decreasing order of difficulty rating and “No” if not. The output should be printed without the quotes.

Each letter of the output may be printed in either lowercase or uppercase. For example, the strings yesYeS, and YES will all be treated as equivalent.

Constraints

Difficulty Rating Order codechef solution

  • 1T1001≤T≤100
  • 2N1002≤N≤100
  • 11≤ difficulty of each problem 5000≤5000

Sample Input 1 

4
3
1 2 3
3
1 1 2
5
100 200 300 400 350
5
1000 2000 5000 3000 1000

Sample Output 1 

Yes
Yes
No
No

Explanation

Difficulty Rating Order codechef solution

Test case 11: 1231≤2≤3. The students have solved problems in increasing order, and so the answer is “Yes”.

Test case 22: 1121≤1≤2. The students have solved problems in non-decreasing order, and so the answer is “Yes”.

Test case 33: 400>350400>350, but the students have solved a 400400-difficulty level problem before solving a 350350-difficulty problem. The students have not solved problems in non-decreasing order, and so the answer is “No”.

Test case 44: 5000>30005000>3000, but the students have solved a 50005000-difficulty level problem before solving a 30003000-difficulty problem. The students have not solved problems in non-decreasing order, and so the answer is “No”.

SOLUTION

Click here

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to Top