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

백준 2217

by 신재권 2022. 7. 15.
package baekjoon.그리디;

import java.util.*;
import java.io.*;

class Main2217{

   public static void main(String[] args) throws Exception {
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      int N = Integer.parseInt(br.readLine());
      PriorityQueue<Integer> pq = new PriorityQueue<>();
      int max = -1;
      for (int i = 0; i < N; i++) {
         pq.add(Integer.parseInt(br.readLine()));
      }
      while (!pq.isEmpty()) {
         max = Math.max(max, pq.poll() * (pq.size()+1));
      }
      System.out.println(max);

   }
}



 

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

백준 16953  (0) 2022.07.17
백준 10162  (0) 2022.07.16
백준 1026  (0) 2022.07.14
백준 1049  (0) 2022.07.12
백준 1339  (0) 2022.07.10