728x90
SMALL

using System;
using System.Linq;

public class Solution {
    public int[] solution(int[,] score) {
        int[] answer = new int[score.GetLength(0)];
        Array.Fill(answer, 1);
        
        for(int i = 0;i < score.GetLength(0);i++)
        {
            for(int j = 0;j < score.GetLength(0);j++)
            {
                if(score[i,0] + score[i,1] > score[j,0] + score[j,1])
                {
                    answer[j]++;
                }
            }
        }
        return answer;
    }
}

 

////

 

자바

 

 

import java.util.*;
class Solution {
    public int[] solution(int[][] score) {
        List<Integer> scoreList = new ArrayList<>();
        
        for(int[] t : score)
        {
            scoreList.add(t[0] + t[1]);
        }
        
        scoreList.sort(Comparator.reverseOrder());
        int[] answer = new int[score.length];
        
        for(int i=0; i<score.length; i++)
        {
            answer[i] = scoreList.indexOf(score[i][0] + score[i][1])+1;
        }
        
        return answer;
    }
}

 

 

class Solution {
    public int[] solution(int[][] score) {
      double[] map = new double[score.length];
      int[] result= new int[score.length];
      
      for (int i = 0; i <score.length ; i++) 
      {
        map[i] = (score[i][0]+ score[i][1])/2.0;
      }

      for (int i = 0; i <score.length ; i++) 
      {
        int count =0;
        
        for (int j = 0; j <score.length ; j++) 
        {
          if(map[i] < map[j])
          {
            count++;
          }
        }
        
        result[i] = count+1;
      }

      return result;
    }
}
728x90

설정

트랙백

댓글