Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.ArrayList;
- import java.util.Collections;
- import java.util.Scanner;
- /**
- * Created by suneetmahajan on 19/01/2018.
- */
- public class p5
- {
- public static void main(String[] args)
- {
- Scanner scan = new Scanner(System.in);
- int n = scan.nextInt();
- int p = scan.nextInt();
- int difficultyLevels;
- ArrayList<Integer> difficulties = new ArrayList<>();
- for (int i = 0; i < p; i++)
- {
- difficultyLevels = scan.nextInt();
- difficulties.add(difficultyLevels);
- }
- int c = scan.nextInt();
- int abilities;
- ArrayList<Integer> abilitiesList = new ArrayList<>();
- for (int index = 0; index < c; index++)
- {
- abilities = scan.nextInt();
- abilitiesList.add(abilities);
- }
- scan.close();
- Collections.sort(difficulties);
- String answer = "no";
- for (int pp = 0; pp < p; pp++)
- {
- int numberOfPeopleWhoSolved = 0;
- int currentProblemDifficulty = difficulties.get(pp);
- for (int yy = 0; yy < c; yy++)
- {
- if ((abilitiesList.get(yy)) >= currentProblemDifficulty)
- {
- numberOfPeopleWhoSolved++;
- }
- }
- if (numberOfPeopleWhoSolved == n)
- {
- answer = "yes";
- pp = p;
- }
- else if (numberOfPeopleWhoSolved < n)
- {
- pp = p;
- }
- }
- System.out.println(answer);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement