|
|
back to boardTLE 8 JAVA Posted by Alex 19 Feb 2019 00:34 import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.*; public class Lesson { public static void main(String[] args) throws Exception { BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in)); int countPrepod = Integer.parseInt(bufferedReader.readLine()); TreeSet<Long> prepod = new TreeSet(); for (int i = 0; i < countPrepod; ++i) { prepod.add(Long.parseLong(bufferedReader.readLine())); } int countStudent = Integer.parseInt(bufferedReader.readLine()); ArrayList<Long> student = new ArrayList(); for (int i = 0; i < countStudent; ++i) { student.add(Long.parseLong(bufferedReader.readLine())); } student.sort(((o1, o2) -> Long.compare(o1,o2))); int result=0; for (long find:prepod) { while (Collections.binarySearch(student,find)>=0) { ++result; student.remove(find); } } System.out.println(result); } } |
|
|