공부기록/프로그래머스
[프로그래머스] 과일 장수
메델
2024. 2. 12. 06:12
import java.util.*;
class Solution {
public int solution(int k, int m, int[] score) {
int answer = 0;
Integer[] scores = new Integer[score.length];
for(int i=0; i<scores.length; i++){
scores[i] = score[i];
}
Arrays.sort(scores, Collections.reverseOrder());
int index = m-1;
for(int i=0; i<scores.length/m; i++){
answer += m * scores[index];
index += m;
}
return answer;
}
}