-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontest.txt
38 lines (31 loc) · 1.08 KB
/
contest.txt
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
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();
}
Arrays.sort(calories);
for(int i = 0; i < calories.length / 2; i++){
int temp = calories[i];
calories[i] = calories[calories.length - i - 1];
calories[calories.length - i - 1] = temp;
}
int nmbrOfcakes = calories.length;
int miles = 0;
int cce = 0;
for(int i=0;i < nmbrOfcakes;i++){
miles = cce + (
(int)calories[i] * (int)java.lang.Math.pow(2,cce));
System.out.println(cce+" "+calories[i]+" "+miles);
cce = cce +1;
}
System.out.print(miles);
}
}