Notice
Recent Posts
문제 풀이 및 개발 공간
[백준] 2303번 숫자 게임 문제! (silver 5 본문
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.StringTokenizer;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
BufferedWriter bw=new BufferedWriter(new OutputStreamWriter(System.out));
StringTokenizer st;
int n=Integer.parseInt(br.readLine());
int[][] card=new int[n+1][5];
int[] units=new int[n+1];
int max=0;
//배열에 카드저장.
for(int i=1; i<n+1; i++) {
st=new StringTokenizer(br.readLine());
for(int j=0; j<5; j++) {
card[i][j]=Integer.parseInt(st.nextToken());
}
}
//모든 경우를 다 해봐서 가장 큰 일의자리 구하기.
int count=0;
for(int t=1; t<n+1; t++) {
for(int i=1; i<5; i++) {
for(int j=i+1; j<5; j++) {
for(int k=j+1; k<5; k++) {
count+=(card[t][i]+card[t][j]+card[t][k])%10;
max= count>max ? count :max;
count=0;
}
}
}
units[t]=max;
max=0;
}
int numOfP=0;
//가장 큰 사람의 번호
for(int i=1; i<n+1; i++) {
if(units[i]>=max) {
numOfP=i;
max=units[i];
}
}
bw.write(numOfP+"");
bw.flush();
}
}
'백준공부 > java' 카테고리의 다른 글
[백준] 1141번 접두사 문제! (silver 1 (0) | 2022.08.10 |
---|---|
[백준] 3711번 학번 문제! (silver 5 (0) | 2022.08.09 |
[백준] 2566번 최댓값 문제! (bronze 3 (0) | 2022.08.08 |
[백준] 4458번 첫 글자를 대문자로 문제! (bronze 3 (0) | 2022.08.08 |
[백준] 1427번 소트인사이드 문제! (silver 5 (0) | 2022.08.08 |