-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDay72.java
More file actions
31 lines (31 loc) · 726 Bytes
/
Copy pathDay72.java
File metadata and controls
31 lines (31 loc) · 726 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
import java.util.*;
public class Day72{
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int tc = in.nextInt();
for (int i=0;i<tc ;i++ ) {
in.nextLine();
String str = in.nextLine();
String strsplit[] = str.split(" ");
int k=Integer.parseInt(strsplit[1]),sum1=0,sum2=0;
boolean check = false;
int arr[] = new int[Integer.parseInt(strsplit[0])];
for (int j=0;j<arr.length ;j++ ) {
arr[j] = in.nextInt();
if (arr[j]>k) {
check = true;
sum1+=arr[j];
sum2+=k;
}else{
sum1+=arr[j];
sum2+=arr[j];
}
}
if (check) {
System.out.println(sum1-sum2);
}else{
System.out.println(0);
}
}
}
}