Difficulty Rating Order

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 practising 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

  • 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-separated 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

  • 1≤T≤1001≤T≤100
  • 2≤N≤1002≤N≤100
  • 1≤1≤ difficulty of each problem ≤5000
//This code is written by Souvik Ghosh
import java.util.*;
public class difficultyRatingOrder {
    public static void main(String[] args) {
        //copy from here for code chef
        Scanner sc = new Scanner(System.in);
        int t=sc.nextInt();
        for (int i = 0; i < t; i++) {
            boolean isD=false;
            int n=sc.nextInt();
            int array[]=new int[n];
            for (int j = 0; j < n; j++) {
                array[j]=sc.nextInt();
            }
            for (int k = 0; k < n-1; k++) {
                if(array[k]>array[k+1]){
                    isD=true;
                    break;

                }
            }
            if(isD==true){
                System.out.println("NO");
            }else{
                System.out.println("YES");
            }
        }
    }
}

Related Posts

CSS Cheatsheet

Transform your web design game with my CSS cheatsheet! Master the art of styling, dive into essential properties and selectors, and create visually stunning websites effortlessly. Whether…

HTML Cheatsheet

Unleash your web development potential with my HTML cheatsheet! Elevate your coding skills, master essential tags and attributes, and build stunning websites with ease. Whether you’re a…

Git&GitHub Cheatsheet

Elevate your Git and GitHub game with my ultimate cheatsheet! Unlock the power of version control, streamline collaboration, and boost productivity. Navigate the complexities of Git commands…

Command Line Cheatsheet

Master the Command Line effortlessly with my comprehensive cheatsheet! Streamline your workflow, boost productivity, and become a command line guru. Unlock essential commands, shortcuts, and tips to…

OpenAI’s APIs Notes

Unlock the potential of OpenAI’s APIs with my comprehensive notes! Dive into the world of cutting-edge artificial intelligence, explore the capabilities of GPT-4 and beyond, and learn…

SQL Notes

Discover the essence of SQL with my comprehensive notes! Dive into the world of Structured Query Language, unraveling the complexities, and mastering database management. Elevate your SQL…

Leave a Reply

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