白駿2798 JAVA
1040 ワード
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);
}
Reference
この問題について(白駿2798 JAVA), 我々は、より多くの情報をここで見つけました https://velog.io/@sunnyinsummer/백준-2798-JAVAテキストは自由に共有またはコピーできます。ただし、このドキュメントのURLは参考URLとして残しておいてください。
Collection and Share based on the CC Protocol