Programmer:)
[ 프로그래머스 / C# ] 과일 장수 본문
반응형
문제 :
https://school.programmers.co.kr/learn/courses/30/lessons/135808
내가 제출한 코드 :
using System;
using System.Linq;
public class Solution {
public int solution(int k, int m, int[] score) {
int answer = 0;
int makeBoxCount = score.Length / m;
var s = from f in score orderby f descending select f;
var listScore = s.ToList();
for (int i = 1; i <= makeBoxCount; i++)
{
int index = (m * i) - 1;
answer += (listScore[index] * m);
}
return answer;
}
}
쿼리문 자꾸 써보려고 연습중~
반응형
'프로그래머스 정복 > C#' 카테고리의 다른 글
[ 프로그래머스 / C# ] 혼자놀기의 달인 (0) | 2022.11.18 |
---|---|
[ 프로그래머스 / C# ] 숫자 카드 나누기 (0) | 2022.11.18 |
[ 프로그래머스 / C# ] K번째 수 (0) | 2022.03.29 |
[ 프로그래머스 / C# ] 음양 더하기 (0) | 2021.10.25 |
[ 프로그래머스 / C# ] 없는숫자 더하기(Except) (0) | 2021.10.22 |
Comments