Advertisement
bizzcuit

контролно

Apr 6th, 2019
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4.  
  5. public static void main(String[] args) {
  6. Scanner in = new Scanner(System.in);
  7. int students = in.nextInt();
  8. int l = in.nextInt();
  9. int r = in.nextInt();
  10.  
  11. int[] noPen = new int[l];
  12. int[] wPen = new int[r];
  13.  
  14. for (int i = 0; i < l; i++) {
  15. noPen[i] = in.nextInt();
  16. }
  17. for (int i = 0; i < r; i++) {
  18. wPen[i] = in.nextInt();
  19. }
  20.  
  21. int countGivenPens = 0;
  22. for (int i = 0; i < wPen.length; i++) {
  23. for (int j = 0; j < noPen.length; j++) {
  24. if (wPen[i] == noPen[j] + 1 || wPen[i] == noPen[j] - 1) {
  25. noPen[j] = -1;
  26. countGivenPens++;
  27. break;
  28. }
  29. }
  30. }
  31. int studentsWPen = students - noPen.length;
  32. System.out.println(students - studentsWPen - countGivenPens);
  33. }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement