-
Notifications
You must be signed in to change notification settings - Fork 2
/
Main.java
42 lines (37 loc) · 1.11 KB
/
Main.java
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
42
package L1_056;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
/**
* @author zmj
* @create 2019/5/7
*/
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.parseInt(br.readLine());
String[] name = new String[105];
Arrays.fill(name, "");
double sum = 0;
for (int i = 0; i < n; i++) {
String[] line = br.readLine().split(" ");
int pos = Integer.parseInt(line[1]);
name[pos] = line[0];
sum += pos;
}
sum = sum / (2*n);
double min = Double.MAX_VALUE;
String res = "";
for (int i = 0; i < 105; i++) {
if (!name[i].isEmpty()) {
double t = Math.abs(i - sum);
if (t < min) {
res = name[i];
min = t;
}
}
}
System.out.println((int)sum + " " + res);
}
}