본문 바로가기
알고리즘 & 자료구조/백준

백준 1015

by 신재권 2022. 9. 7.
package baekjoon.정렬;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

class Main1015 {

   static int[] A, B;
   static int N;
   static StringBuilder sb = new StringBuilder();

   public static void main(String[] args) throws Exception {
      input();
      Arrays.sort(B);
      find();
      System.out.println(sb);
   }

   private static void find() {
      for (int i = 0; i < N; i++) {
         int a = A[i];
         for (int j = 0; j < N; j++) {
            if (a == B[j]) {
               sb.append(j).append(' ');
               B[j] = -1;
               break;
            }
         }
      }
   }

   private static void input() throws IOException {
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      StringTokenizer st;
      N = Integer.parseInt(br.readLine());
      st = new StringTokenizer(br.readLine());
      A = new int[N];
      B = new int[N];
      for (int i = 0; i < N; i++) {
         int num = Integer.parseInt(st.nextToken());
         A[i] = num;
         B[i] = num;
      }
   }
}



 

'알고리즘 & 자료구조 > 백준' 카테고리의 다른 글

백준 15970  (0) 2022.09.07
백준 11652  (0) 2022.09.07
백준 10825  (0) 2022.09.06
백준 2475  (0) 2022.08.28
백준 10757  (0) 2022.08.24