-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTask07.java
More file actions
29 lines (22 loc) · 808 Bytes
/
Task07.java
File metadata and controls
29 lines (22 loc) · 808 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;
public class Task07 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int M = in.nextInt();
int L = in.nextInt();
String garbage = in.nextLine();
Map<Integer, Integer> prisoners = new TreeMap<>();
for(int i=0; i<L; i++) {
String line = in.nextLine();
String[] elements = line.split(" ");
prisoners.put(Integer.parseInt(elements[2]), Integer.parseInt(elements[1]));
}
for(int j=0; j<M; j++) {
Map.Entry<Integer,Integer> entry = prisoners.entrySet().iterator().next();
System.out.println(entry.getValue());
prisoners.remove(entry.getKey());
}
}
}