-
-
Notifications
You must be signed in to change notification settings - Fork 109
Expand file tree
/
Copy pathMarc'sCakewalk.java
More file actions
28 lines (25 loc) · 704 Bytes
/
Copy pathMarc'sCakewalk.java
File metadata and controls
28 lines (25 loc) · 704 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
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Solution {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
int[] calories = new int[n];
for(int calories_i=0; calories_i < n; calories_i++){
calories[calories_i] = in.nextInt();
}
method1(calories, n);
}
public static void method1(int[] c,int n) {
Arrays.sort(c);
long sum = 0;
int num = 0;
for(int i=n-1;i>=0;i--) {
sum += ((long)(Math.pow(2, num++)) * c[i]);
}
System.out.println(sum);
}
}