Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- 18222
- Java
- EC2
- dockercompose
- 이산수학
- SpringBoot
- 2167. 2차원 배열의 합
- jenkins
- 자바
- 14466
- 별자리 만들기
- docker
- 백준
- to display the conditions report re-run your application with 'debug' enabled
- 21278
- 날짜일수
- CMD
- 설정
- documentationpluginsbootstrapper
- 프로그래머스
- 2108_통계학
- Error
- 소가길을건너간이유6
- Eclipse
- 알고리즘
- 호석이두마리치킨
- Error fetching remote repo 'origin'
- 20055
- 이클립스
- 투에모스문자열
Archives
- Today
- Total
계단을 오르듯이
18429. 근손실 본문
package argust.fourweek;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class B_18429_근손실 {
static int count;
public static void main(String[] args) throws Exception {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
StringBuilder sb = new StringBuilder();
StringTokenizer st = new StringTokenizer(in.readLine(), " ");
int N = Integer.parseInt(st.nextToken());
int K = Integer.parseInt(st.nextToken());
int[] arr = new int[N];
boolean[] check = new boolean[N];
int[] w = new int[N];
st = new StringTokenizer(in.readLine(), " ");
for (int i = 0; i < N; i++) {
arr[i] = Integer.parseInt(st.nextToken());
}
perm(0, N, K, arr, check, w);
System.out.println(sb.append(count));
}
private static void perm(int cnt, int N, int K, int[] arr, boolean[] check, int[] w) {
if (cnt == N) {
int now = 500;
for (int i = 0; i < N; i++) {
now += w[i] - K;
if (now < 500)
return;
}
count++;
return;
}
for (int i = 0; i < N; i++) {
if (check[i])
continue;
check[i] = true;
w[cnt] = arr[i]; // 중량넣기
perm(cnt + 1, N, K, arr, check, w);
check[i] = false;
}
}
}
'알고리즘 > 백준_JAVA' 카테고리의 다른 글
17478. 재귀함수가 뭔가요? (0) | 2021.12.31 |
---|---|
17836. 공주님을 구해라 (0) | 2021.12.31 |
20154. 이 구역의 승자는 누구야 (0) | 2021.12.31 |
1912. 연속합 (0) | 2021.12.31 |
20291. 파일 정리 (0) | 2021.12.30 |