Dev.baelanche

[백준 5533] 유니크 본문

Data Structure & Algorithm/PS - JAVA

[백준 5533] 유니크

baelanche 2019. 4. 12. 21:12
반응형

 

이차원배열을 세로로 탐색하면서 점수를 비교하였다.

 

 

public class Main {
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        int a[][] = new int[n][3];
        int score[] = new int[n];
        
        for(int i=0; i<n; i++) {
            for(int j=0; j<3; j++) {
                a[i][j] = sc.nextInt();
            }
        }
        
        int sum = 0;
        for(int i=0; i<3; i++) {
            for(int j=0; j<n; j++) {
                for(int k=0; k<n; k++) {
                    if(j==k) continue;
                    if(a[j][i] != a[k][i]) sum = a[j][i];
                    else {sum = 0; break;}
                }
                score[j] += sum;
                sum = 0;
            }
        }
        
        for(int i=0; i<n; i++)
            System.out.println(score[i]);
        sc.close();
    }
}
반응형

'Data Structure & Algorithm > PS - JAVA' 카테고리의 다른 글

[백준 10409] 서버  (0) 2019.04.12
[백준 2804] 크로스워드 만들기  (0) 2019.04.12
[백준 5212] 지구 온난화  (0) 2019.04.11
[백준 10539] 수빈이와 수열  (0) 2019.04.11
[백준 5567] 결혼식  (0) 2019.04.11
Comments