알고리즘/문제 [BOJ/백준 - 1946] 신입 사원 - 문제 출처:https://www.acmicpc.net/problem/1946 1946번: 신입 사원 첫째 줄에는 테스트 케이스의 개수 T(1 ≤ T ≤ 20)가 주어진다. 각 테스트 케이스의 첫째 줄에 지원자의 숫자 N(1 ≤ N ≤ 100,000)이 주어진다. 둘째 줄부터 N개 줄에는 각각의 지원자의 서류심사 성 www.acmicpc.net This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters Show hidden characters public class Main { public static void main(String[] args) throws Exception{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int testCase = Integer.parseInt(br.readLine()); StringTokenizer st; while(testCase > 0) { // Init int length = Integer.parseInt(br.readLine()); Sawon[] arr = new Sawon[length]; for(int i=0; i<arr.length; i++) { st = new StringTokenizer(br.readLine()); int a = Integer.parseInt(st.nextToken()); int b = Integer.parseInt(st.nextToken()); arr[i] = new Sawon(a, b); } // Sort Arrays.sort(arr); int temp = 0; int minB = arr[0].b; for(int i=0; i<arr.length; i++) { if(minB < arr[i].b) { temp++; }else { minB = arr[i].b; } } System.out.println(arr.length - temp); testCase--; } } } class Sawon implements Comparable<Sawon>{ int a; int b; public Sawon(int a, int b) { this.a = a; this.b = b; } @Override public int compareTo(Sawon o) { return this.a - o.a; } } view raw BOJ_1946.java hosted with ❤ by GitHub 나는 앞의 점수를 오름차순 정렬 후 맨 앞을 기준 데이터로 저장했다 다음 원소를 비교하면서 기준 데이터와 뒤 점수를 비교해서 (앞의 점수는 정렬이 되었기 때문에 비교하지 않는다) 기준 데이터가 더 작을 경우 temp값을 올려주고 기준 데이터가 더 클 경우 현재 확인중인 원소를 기준데이터로 옮겨준다 그리고 해당 문단의 첫번째로 가서 반복한다 속도가 매우 느리게 통과했는데 (3100ms) 다른 사람 코드좀 봐봐야겠다 공유하기 URL 복사카카오톡 공유페이스북 공유엑스 공유 게시글 관리 구독하기Time to lazy Contents 당신이 좋아할만한 콘텐츠 [BOJ/백준 - 13904] 과제 2022.01.11 [BOJ/백준 - 1339] 단어 수학 2022.01.10 [BOJ/백준 - 1931] 회의실 배정 2022.01.09 [BOJ/백준 - 1046] 에디터 2022.01.09 댓글 0 + 이전 댓글 더보기