Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Collections;
- import java.util.Comparator;
- import java.util.LinkedList;
- import java.util.PriorityQueue;
- import java.util.Scanner;
- public class RoundRobin {
- public static void main(String[] args) {
- Scanner in = new Scanner(System.in);
- int n = Integer.parseInt(in.nextLine());
- LinkedList<Proces> ll = new LinkedList<Proces>();
- for(int i=0; i<n; i++)
- {
- String line = in.nextLine();
- String [] parts = line.split(" ");
- ll.add(new Proces(parts[0],Integer.parseInt(parts[1])
- , Integer.parseInt(parts[2])));
- }
- int odzemach = Integer.parseInt(in.nextLine());
- ll.sort(Comparator.comparing(Proces::getPristig)
- .thenComparing(Proces::getIzvrs_));
- while(ll.size()>0)
- {
- Proces pr = ll.removeFirst();
- System.out.print(pr.ime+" ");
- pr.obnovi(odzemach);
- if(pr.getIzvrs()>0)
- ll.add(pr);
- }
- }
- }
- class Proces
- {
- String ime;
- int izvrs, pristig;
- Proces()
- {
- this.ime = "";
- this.izvrs = 0;
- this.pristig = 0;
- }
- Proces(String ime, int izvrs, int pristig)
- {
- this.ime = ime;
- this.izvrs = izvrs;
- this.pristig = pristig;
- }
- int getPristig()
- {
- return pristig;
- }
- int getIzvrs()
- {
- return izvrs;
- }
- int getIzvrs_()
- {
- return -izvrs;
- }
- void obnovi(int n)
- {
- this.izvrs-=n;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement