-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathNumberOfChicken.java
More file actions
51 lines (34 loc) · 859 Bytes
/
NumberOfChicken.java
File metadata and controls
51 lines (34 loc) · 859 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
package company;
import java.util.Arrays;
import java.util.Scanner;
/**
* @Author: Wenhang Chen
* @Description:
* @Date: Created in 19:03 3/30/2020
* @Modified by:
*/
public class NumberOfChicken {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int m = sc.nextInt();
int k = sc.nextInt();
long[] a = new long[n];
long num = 0;
for (int i = 0; i < n; i++) {
a[i] = sc.nextInt();
}
Arrays.sort(a);
for (int i = 0; i < m; i++) {
for (int j = 0; j < n; j++) {
a[j] += k;
}
a[n - 1] /= 2;
Arrays.sort(a);
}
for (int i = 0; i < n; i++) {
num += a[i];
}
System.out.println(num);
}
}