회원가입
로그인
Toggle navigation
문제
문제
전체 문제
문제 출처
단계별로 풀어보기
알고리즘 분류
추가된 문제
문제 순위
문제
푼 사람이 한 명인 문제
아무도 못 푼 문제
최근 제출된 문제
최근 풀린 문제
랜덤
출처
ICPC
Olympiad
한국정보올림피아드
한국정보올림피아드시․도지역본선
전국 대학생 프로그래밍 대회 동아리 연합
대학교 대회
카카오 코드 페스티벌
Coder's High
ICPC
Regionals
World Finals
Korea Regional
Africa and the Middle East Regionals
Europe Regionals
Latin America Regionals
North America Regionals
South Pacific Regionals
문제집
대회
채점 현황
게시판
그룹
더 보기
재채점 기록
블로그
도움말
전체
공지
자유
질문
오타/오역/요청
게시판 공지
홍보
업데이트
solved.ac
글쓰기
질문 도움말
자주묻는 질문
왜 틀린지 모르겠습니다
7568번 - 덩치
minjibb99
3년 전
0
여기서 찾아본 반례나 예제는 모두 통과되는데 제출 시 틀렸다고 뜹니다.
import java.util.*; import java.io.*; 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)); int N = Integer.parseInt(br.readLine()); String[] people = new String[N]; for (int i = 0; i < N; i++) { people[i] = br.readLine(); } String[] saram = people.clone(); Arrays.sort(people, new Comparator<String>() { public int compare(String s1, String s2) { String[] split1 = s1.split(" "); String[] split2 = s2.split(" "); int weight1 = Integer.parseInt(split1[0]); int weight2 = Integer.parseInt(split2[0]); return Integer.compare(weight1, weight2); } }); Map<String, Integer> result = new HashMap<>(); int score = 1; int count = 0; result.put(people[people.length-1], 1); for (int i = people.length-1; i >= 0 ; i--) { if (i == people.length-1){ int height1 = Integer.parseInt(people[i].split(" ")[1]); int height2 = Integer.parseInt(people[i-1].split(" ")[1]); if (height1>height2) { result.put(people[i], count + score); count = 0; } else { result.put(people[i], score); count++; } } else { int weight1 = Integer.parseInt(people[i].split(" ")[0]); int weight2 = Integer.parseInt(people[i+1].split(" ")[0]); int height1 = Integer.parseInt(people[i+1].split(" ")[1]); int height2 = Integer.parseInt(people[i].split(" ")[1]); if (weight1 == weight2){ result.put(people[i], score); count++; } else if (height1>height2) { score++; result.put(people[i], count + score); count = 0; } else { result.put(people[i], score); count++; } } } for (String str : saram) { bw.write(String.valueOf(result.get(str))+" "); } bw.flush(); } }
댓글을 작성하려면
로그인
해야 합니다.
minjibb99 3년 전
여기서 찾아본 반례나 예제는 모두 통과되는데 제출 시 틀렸다고 뜹니다.