package D3;
import java.util.Scanner;
public class 한빈이와spotmart {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int T = sc.nextInt(); // 테케 수
for(int tc = 1; tc<=T; tc++) {
int N = sc.nextInt(); // 봉지 개수 6
int M = sc.nextInt(); // 무게 합 제한 10
int a[] = new int[N];// 각 과자봉지의 무게 1 2 5 8 9 11
//봉지를 만들어서 무게 넣어줄 공간
for(int i = 0; i<N; i++) {
a[i] = sc.nextInt();
}
int max =-1;
//int ans =-1;
for(int i =0; i<N; i++) {
for(int j=i+1; j<N; j++) {
if(a[i]+a[j]<=M && a[i]+a[j]>max ) {
//max = a[i] + a[j]; 최대값구하기
max=Math.max(a[i]+a[j],max); // 최대값구하기2
}
}
}
System.out.print("#"+tc +" " + max+"\n");
}
}
}
'알고리즘 > SwExpert recipe' 카테고리의 다른 글
SWEA 암호문1 [D3] (0) | 2021.02.09 |
---|---|
SWEA 간단한소인수분해 [D2] (0) | 2021.02.09 |
SWEA 중간평균값구하기 [D2] (0) | 2021.02.08 |
SWEA SUM2 [D3] (0) | 2021.02.08 |
SWEA 계산기2 [D4] (0) | 2021.02.07 |