acmicpc.net/status?user_id=sunnyleewin&problem_id=2798&from_mine=1
블랙잭 문제를 풀었다.
package BlackJack;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int N = input.nextInt();
int M = input.nextInt();
int result = 0;
int[] ar = new int[N];
for(int i = 0; i< N; i++)
ar[i] = input.nextInt();
for(int i = 0; i < N - 2; i++) {
for(int j = i + 1; j < N -1; j++) {
for(int k = j + 1; k < N; k++) {
int temp = ar[i] + ar[j] + ar[k];
if(temp <= M) {
result = temp;
}
else if(result < M && temp < M) {
result = temp;
}
}
}
}
System.out.println(result);
}