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

백준 7568

by 신재권 2022. 8. 16.
package baekjoon.구현;

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

class Main7568 {

   public static void main(String[] args) throws Exception {
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      StringTokenizer st;
      int N = Integer.parseInt(br.readLine());
      Pair[] p = new Pair[N + 1];
      for (int i = 0; i < N; i++) {
         st = new StringTokenizer(br.readLine());
         p[i] = new Pair(Integer.parseInt(st.nextToken()), Integer.parseInt(st.nextToken()));
      }

      StringBuilder sb = new StringBuilder();
      for (int i = 0; i < N; i++) {
         int cnt = 0;
         for (int j = 0; j < N; j++) {
            if (i != j) {
               if (p[i].y < p[j].y && p[i].x < p[j].x) {
                  cnt++;
               }
            }
         }
         sb.append(cnt + 1).append(' ');
      }
      System.out.println(sb);
   }

   private static class Pair {
      int x, y;

      public Pair(int x, int y) {
         this.x = x;
         this.y = y;
      }
   }
}

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

백준 11721  (0) 2022.08.19
백준 1924  (0) 2022.08.17
백준 2847  (0) 2022.08.15
백준 1700  (0) 2022.08.13
백준 1783  (0) 2022.08.12