Advertisement
Guest User

Untitled

a guest
Jan 20th, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.64 KB | None | 0 0
  1. import java.util.ArrayList;
  2. import java.util.Collections;
  3. import java.util.Scanner;
  4.  
  5. /**
  6. * Created by suneetmahajan on 19/01/2018.
  7. */
  8. public class p5
  9. {
  10. public static void main(String[] args)
  11. {
  12. Scanner scan = new Scanner(System.in);
  13. int n = scan.nextInt();
  14. int p = scan.nextInt();
  15.  
  16. int difficultyLevels;
  17. ArrayList<Integer> difficulties = new ArrayList<>();
  18.  
  19. for (int i = 0; i < p; i++)
  20. {
  21. difficultyLevels = scan.nextInt();
  22.  
  23. difficulties.add(difficultyLevels);
  24.  
  25. }
  26.  
  27. int c = scan.nextInt();
  28.  
  29. int abilities;
  30.  
  31. ArrayList<Integer> abilitiesList = new ArrayList<>();
  32.  
  33. for (int index = 0; index < c; index++)
  34. {
  35. abilities = scan.nextInt();
  36.  
  37. abilitiesList.add(abilities);
  38. }
  39.  
  40. scan.close();
  41.  
  42. Collections.sort(difficulties);
  43.  
  44. String answer = "no";
  45.  
  46. for (int pp = 0; pp < p; pp++)
  47. {
  48. int numberOfPeopleWhoSolved = 0;
  49.  
  50. int currentProblemDifficulty = difficulties.get(pp);
  51.  
  52. for (int yy = 0; yy < c; yy++)
  53. {
  54.  
  55. if ((abilitiesList.get(yy)) >= currentProblemDifficulty)
  56. {
  57. numberOfPeopleWhoSolved++;
  58. }
  59.  
  60. }
  61.  
  62. if (numberOfPeopleWhoSolved == n)
  63. {
  64. answer = "yes";
  65. pp = p;
  66. }
  67.  
  68. else if (numberOfPeopleWhoSolved < n)
  69. {
  70. pp = p;
  71. }
  72.  
  73. }
  74.  
  75. System.out.println(answer);
  76. }
  77. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement