OJ
[BOJ] 2303 숫자 게임 (JAVA)
P3PP4
2023. 3. 7. 10:00
https://www.acmicpc.net/problem/2303
2303번: 숫자 게임
N명이 모여 숫자 게임을 하고자 한다. 각 사람에게는 1부터 10사이의 수가 적혀진 다섯 장의 카드가 주어진다. 그 중 세 장의 카드를 골라 합을 구한 후 일의 자리 수가 가장 큰 사람이 게임을 이
www.acmicpc.net
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class Main {
static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
static StringTokenizer st;
static int N, max, maxIndex;
public static void main(String[] args) throws Exception {
N = Integer.parseInt(br.readLine());
for (int i = 1; i <= N; i++) {
int[] n = new int[5];
st = new StringTokenizer(br.readLine(), " ");
n[0] = Integer.parseInt(st.nextToken());
n[2] = Integer.parseInt(st.nextToken());
n[1] = Integer.parseInt(st.nextToken());
n[3] = Integer.parseInt(st.nextToken());
n[4] = Integer.parseInt(st.nextToken());
for (int j = 0; j < 3; j++) {
for (int k = j + 1; k < 4; k++) {
for (int l = k + 1; l < 5; l++) {
int temp = (n[j] + n[k] + n[l]) % 10;
if (max <= temp) {
max = temp;
maxIndex = i;
}
}
}
}
}
System.out.print(maxIndex);
}
}