-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathcups.java
More file actions
41 lines (33 loc) · 766 Bytes
/
cups.java
File metadata and controls
41 lines (33 loc) · 766 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
30
31
32
33
34
35
36
37
38
39
40
41
import java.util.Scanner;
import java.util.HashMap;
import java.util.ArrayList;
import java.util.Collections;
public class cups {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int cases = scan.nextInt();
HashMap<Integer , String> map = new HashMap<>();
ArrayList<Integer> nums = new ArrayList<>();
for (int i = 0; i < cases; i++)
{
try
{
int radius = scan.nextInt() / 2;
String color = scan.next();
map.put(radius, color);
nums.add(radius);
}
catch (Exception e)
{
String color = scan.next();
int radius = scan.nextInt();
map.put(radius , color);
nums.add(radius);
}
}
Collections.sort(nums);
for (int i = 0; i < nums.size(); i++)
System.out.println(map.get(nums.get(i)));
scan.close();
}
}