목록알고리즘/[2020] 프로그래머스 (19)
게하! 개하! (게임도 하고 개발도 하고)
import java.util.*; class Solution { public int solution(int[][] routes) { int answer = 1; Arrays.sort(routes, new Comparator(){ public int compare(int[]o1, int[]o2){ if(o1[0]==o2[0]) return Integer.compare(o1[1],o2[1]); return Integer.compare(o1[0],o2[0]); } }); int result = routes[0][1]; for(int i =1; iroutes[i][1]){ result = routes[i][1]; } if(result
import java.util.Collections; import java.util.ArrayList; import java.util.List; class Solution { public int solution(int[] budgets, int M) { int answer = 0; int max = 0; for (int i = 0; i < budgets.length; i++) { max = Math.max(budgets[i], max); } int first = 0; int end = max; while(true){ long result=0; if(first>end){ break; } int middle = (first+end)/2; for(int i = 0 ; imiddle){ result+=middl..
class Solution { public int solution(int n) { int answer = 0; int a=1; int b=1; for(int i = 1 ; i