package bfBlackjack;
import java.util.Scanner;
class blackJack
{
public int BFblackjack(int[] tempArr,int n, int m)
{
int[] iArr= new int[n];
iArr=tempArr;
int sum = 0;
int temp=0;
for(int i=0;i<n;i++)
{
for(int j=(i+1);j<n;j++)
{
for(int k=(j+1);k<n;k++)
{
temp=(iArr[i]+iArr[j]+iArr[k]);
if(temp<=m&&temp>sum)
{
sum=temp;
}
}
}
}
return sum;
}
}
public class Main {
public static void main(String[] args)
{
blackJack test=new blackJack();
Scanner scanner = new Scanner(System.in);
int n=0;
int m=0;
n=scanner.nextInt();
m=scanner.nextInt();
int[] iArr= new int[n];
for(int i=0;i<n;i++)
{
iArr[i]=scanner.nextInt();
}
System.out.println(test.BFblackjack(iArr,n,m));
scanner.close();
}
}
'알고리즘' 카테고리의 다른 글
[BAEKJOON 10809번] (Java) 알파벳 찾기 (0) | 2020.06.18 |
---|---|
[BAEKJOON 2292번] (Java) 벌집 (0) | 2020.06.18 |
[BAEKJOON 1065번] (Java) 한수 (0) | 2020.06.18 |
[BAEKJOON 2941번] (Java) 크로아티아 알파벳 (0) | 2020.06.15 |
[BAEKJOON 10250번] (Java) ACM호텔 (0) | 2020.06.15 |