-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmuscle18429.java
More file actions
43 lines (38 loc) · 1.2 KB
/
Copy pathmuscle18429.java
File metadata and controls
43 lines (38 loc) · 1.2 KB
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
39
40
41
42
43
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class muscle18429 {
public static int n,k;
public static int[] arr;
public static boolean[] check;
public static int cnt;
public static void main(String[] args)throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTokenizer(br.readLine());
n = Integer.parseInt(st.nextToken());
k = Integer.parseInt(st.nextToken());
arr = new int[n];
st = new StringTokenizer(br.readLine());
for(int i = 0; i < n; i++){
arr[i] = Integer.parseInt(st.nextToken());
}
check = new boolean[n];
cnt = 0;
solve(500,0);
System.out.println(cnt);
}
public static void solve(int sum, int depth){
if(depth == n){
cnt++;
return;
}
for(int i = 0; i < n; i++){
if(!check[i] && (sum+arr[i]-k)>=500){
check[i] = true;
solve(sum+arr[i] -k,depth+1);
check[i] =false;
}
}
}
}