-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathpassword.java
27 lines (25 loc) · 891 Bytes
/
password.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
import java.io.*;
import java.util.*;
public class password {
public static void main(String[] args) throws Exception {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
StringTokenizer st = new StringTokenizer(in.readLine());
int n = Integer.parseInt(st.nextToken());
double[] prob = new double[n];
for(int i = 0; i < n; i++) {
st = new StringTokenizer(in.readLine());
st.nextToken();
prob[i] = Double.parseDouble(st.nextToken());
}
Arrays.sort(prob);
int attempt = 1;
double exp = 0;
for(int i = n - 1; i >= 0; i--) {
exp += attempt * prob[i];
attempt++;
}
out.println(exp);
out.close();
}
}