프로그래머스 - 과일 장수
풀이
- score 정렬
 
- score의 길이가 m 단위로 나누어떨어지면 버리게 되는 사과 발생
➡️ 버리는 사과의 개수를 구해줌 
- m 단위로 나눴을 때 각 파티션마다 가장 작은 수를 모두 더한 후 m을 곱한 값을 리턴
 
코드
import java.util.Arrays;
public class FruitSeller {
	public int solution(int k, int m, int[] score) {
		Arrays.sort(score);
		int sum = 0;
		int start = score.length % m;
		for (int i = start; i < score.length; i += m) {
			sum += score[i];
		}
		return sum * m;
	}
	public static void main(String[] args) {
		FruitSeller fruitSeller = new FruitSeller();
		System.out.println(fruitSeller.solution(3, 4, new int[]{1, 2, 3, 1, 2, 3, 1})); 
		System.out.println(fruitSeller.solution(4, 3, new int[]{4, 1, 2, 2, 4, 4, 4, 4, 1, 2, 4, 2}));  
	}
}