Competitive programming
I need code in java

Description
N students are participating in defending their homework assignment. The defense is conducted by a professor and an assistant. The assistant can review the work of only one student at a time, while the professor is capable of overseeing only two defenses simultaneously (he refuses to conduct a defense for just one student). We will simulate the defense with separate threads - one for the assistant and two for the professor. Defenses can start as soon as both the assistant's and the professor's threads are ready to work. The professor and the assistant are available within the next 5 seconds from the start, after which defenses are no longer possible.
Each student arrives for defense at a random time - a random value within the range of 0 < x <= 1 second from the start of the defense. Each student defends the task at their own pace - a random value in the range of 0.5 <= X <= 1 second, after which they receive a grade and finish. Since defenses last for 5 seconds, a defense that has started must be terminated when the 5 seconds expire.
The professor refuses to conduct a review for only one student and will wait for two students ready to defend before starting the review for both students in parallel, waiting for both to finish.
The assistant conducts the review as soon as a student is ready for defense.
The probability that a student will defend with the professor or assistant is of choice (e.g., 50% to defend with the professor and 50% to defend with the assistant).
After completing their defense, each student receives a grade between 5 and 10. The received grades should be added to the sum of all students' grades. This sum will be divided by the number of students after the program ends (after the expiration of the 5 seconds designated for defense), and the resulting average should be printed in the console. This average must be accurate regardless of the number of students.
It must not happen that the same student defends the assignment twice. It must not happen that a student defends the assignment after the expiration of the time designated for defenses (5 seconds), even if they started before the end. It must not happen that the professor and the assistant conduct a review for the same student.
The input parameter of the system is N, the number of students.
The system output should be printed in the following format for all students who arrived or were interrupted during the defense:
Thread: Arrival: Prof: TTC: : Score:
For creating threads, use a thread pool of any type (except singleThreadPool). For the professor, implement a cyclicBarrier when waiting for two students to start defending with him.

Q&A Education