Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Konsultacii;
- import java.io.BufferedReader;
- import java.io.IOException;
- import java.io.InputStreamReader;
- import java.util.ArrayDeque;
- public class Konsultacii {
- public static void main(String[] args) throws NumberFormatException, IOException {
- BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
- ArrayDeque<Student> aps = new ArrayDeque<Student>();
- ArrayDeque<String> mms = new ArrayDeque<String>();
- int broj_aps = Integer.parseInt(br.readLine());
- int brojac = 0;
- for (int i = 0; i < broj_aps; i++) {
- String[] student_podelen = br.readLine().split(" ");
- Student st = new Student(student_podelen[0], student_podelen[1]);
- aps.add(st);
- }
- int broj_mms = Integer.parseInt(br.readLine());
- for (int i = 0; i < broj_mms; i++)
- mms.add(br.readLine());
- String temp = null;
- while (!aps.isEmpty()) {
- Student st = aps.poll();
- if (!st.tip.equals(temp)) {
- temp = st.tip;
- System.out.println(st.ime);
- } else if (st.tip.equals(temp)) {
- brojac++;
- if (brojac > 3) {
- brojac = 0;
- System.out.println(st.ime);
- } else
- aps.add(st);
- if (!mms.isEmpty())
- System.out.println(mms.poll());
- }
- }
- }
- }
- class Student {
- public String ime;
- public String tip;
- public Student(String ime, String tip) {
- this.ime = ime;
- this.tip = tip;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement