Created
May 9, 2021 03:27
-
-
Save SnowyPainter/a0fc8189a453580b0d656e96dde1676e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
//알고리즘 문제해결전략 | |
//록 페스티벌 | |
//풀이 핵심 | |
// 1. 기능을 따로 보라 | |
// 2. 필요에 의해 하라 | |
int main() | |
{ | |
int c; | |
float *results = new float[c]; | |
cin >> c; | |
for (int i = 0; i < c; i++) | |
{ | |
int n, l; | |
cin >> n >> l; | |
int *lend_costs = new int[n]; | |
for (int j = 0; j < n; j++) | |
{ | |
cin >> lend_costs[j]; | |
} | |
float min_cost_mean = 100; | |
for (int j = 0; j < n; j++) | |
{ | |
if (j + l >= n) | |
break; | |
for (int o = 0; o < n - (j + l); o++) | |
{ | |
float cost_sum = 0; | |
for (int k = j; k < l + j + o; k++) | |
{ | |
cost_sum += lend_costs[k]; | |
} | |
float d = cost_sum / (l + o); | |
if (min_cost_mean > d) | |
min_cost_mean = d; | |
} | |
} | |
results[i] = min_cost_mean; | |
} | |
for (int i = 0; i < c; i++) | |
cout << results[i] << endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment