문제 출처
Java
import java.util.*;
class Solution {
public int solution(int k, int m, int[] score) {
int answer = 0;
Arrays.sort(score);
int [] tScore = new int[score.length];
for (int i= 0; i<score.length; i++){
tScore[i] = score[score.length -1 -i];
}
int index = 0;
while (true){
if (index >= tScore.length || index + m > tScore.length) { break;}
answer += tScore[index +m-1] * m;
index += m;
}
return answer;
}
}
Kotlin
class Solution {
fun solution(k: Int, m: Int, score: IntArray): Int {
var answer: Int = 0
val score = score.sorted().reversed()
var index : Int = 0
while (true){
if(index >= score.size || index+m > score.size){
break
}
answer += score[index+ m -1] * m
index += m
}
return answer
}
}