• 카테고리

    질문 & 답변
  • 세부 분야

    알고리즘 · 자료구조

  • 해결 여부

    미해결

안녕하세요 테스트케이스 관련 문의드립니다.

22.12.31 16:00 작성 조회수 194

0

씨름선수 문제에서 이중반복문으로 제일 처음 문제풀이를 했는데 정답으로 떴습니다. 다른 수강생분들 게시글을 찾다가 저랑 동일한 경우를 발견했습니다!! 답글에 테스트케이스 수정해놓겠다고 하셨는데.. 혹시 수정했는데도 저와 같은 경우가 또 생길까봐 글 올립니다!!

class Participant{
    int weight;
    int height;

    public Participant(int height, int weight){
        this.height = height;
        this.weight = weight;
    }
}

public class Code05 {
    public static ArrayList<Participant> list;
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        list = new ArrayList<>();
        for(int i=0; i<n; i++){
            int height = sc.nextInt();
            int weight = sc.nextInt();
            list.add(new Participant(height, weight));
        }

        System.out.println(solution());
    }

    public static int solution(){
        boolean flag = false;
        int remove = 0;
        for(int i=0; i<list.size(); i++){
            Participant comp = list.get(i);
            for(int j=0; j<list.size(); j++){
                if(i==j) continue;
                if((comp.weight < list.get(j).weight) && (comp.height < list.get(j).height)) flag = true;
            }
            if(flag) {
                remove++;
                flag = false;
            }
        }
        return list.size() - remove;
    }
}

답변 1

답변을 작성해보세요.

0

안녕하세요^^

네. 감사합니다. 제가 잊어버린 것 같습니다. 수정하고 님걸로 테스트 해보겠습니다.

감사합니다. 새해 복 많이 받으세요!!