pullwall
Well done! 코딩
pullwall
전체 방문자
오늘
어제
  • 분류 전체보기 (151)
    • 개발환경 (2)
    • java study (21)
    • 백준 단계별 (51)
    • 알고리즘 (3)
    • AI (43)
    • 클라우드 (3)
      • Kubernetes in Google (3)
    • 논문 (5)
    • 리눅스 (1)
    • AWS (4)
    • 수학 (15)
    • 기타 (1)

블로그 메뉴

  • 홈
  • 태그
  • 방명록

공지사항

인기 글

태그

  • 정렬알고리즘
  • Java
  • 수학
  • 자바독학
  • 백준 단계별
  • Ai
  • 쿠버네티스
  • 알고리즘
  • 단계별
  • 선택정렬
  • 자바
  • 정렬
  • pytorch
  • Google
  • LLM
  • AWS
  • 논문리뷰
  • Kubernetes
  • 백준
  • dataset

최근 댓글

최근 글

티스토리

hELLO · Designed By 정상우.
pullwall

Well done! 코딩

백준 단계별

[Java] 백준 25305: 커트라인

2023. 2. 2. 14:37
728x90

 

import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int[] arr = new int[N];
        int k = sc.nextInt();

        for(int i=0 ; i<N ; i++){
            arr[i] = sc.nextInt();
        }

        for(int i=0;i<N;i++){
            int minindex=i;
            for(int j=i+1;j<N;j++){
                if(arr[minindex]>arr[j]){
                    minindex=j;
                }
            }

            int tmp=arr[i];
            arr[i]=arr[minindex];
            arr[minindex]=tmp;
        }
        
        System.out.println(arr[N-k]);
    }
}

https://welldonecode.tistory.com/73

 

[Java] 정렬 알고리즘 - 선택정렬(Selection Sort)

import java.util.Arrays; public class Main { public static void main(String[] args){ int[] arr = {7, 5, 9, 0, 3, 1, 6, 2, 4, 8}; for(int i=0; i

welldonecode.tistory.com

 

 

 

정렬 알고리즘으로 배열을 정렬한 후

 

5명중 2명을 뽑는다면 커트라인은 정렬했을때의 4번째 참가자의 성적이 되므로

 

arr[N-k]를 출력하면 된다.

728x90

'백준 단계별' 카테고리의 다른 글

[Java] 백준 10989: 수 정렬하기 3  (0) 2023.02.14
[Java] 백준 2751: 수 정렬하기 2  (0) 2023.02.08
[Java] 백준 2587: 대표값2  (0) 2023.02.02
[Java] 백준 2750: 수 정렬하기  (0) 2023.02.02
[Java] 백준 2563: 색종이  (0) 2023.01.26
    '백준 단계별' 카테고리의 다른 글
    • [Java] 백준 10989: 수 정렬하기 3
    • [Java] 백준 2751: 수 정렬하기 2
    • [Java] 백준 2587: 대표값2
    • [Java] 백준 2750: 수 정렬하기
    pullwall
    pullwall

    티스토리툴바