1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | #include <iostream>
int main()
{
int number_of_bottles_needed;
int number_of_rows;
int plaszcz;
int dane;
int min = 2020;
std::cin >> number_of_rows;
std::cin >> number_of_bottles_needed;
for (int i = 1; i <= number_of_rows; ++i)
{
plaszcz = 0;
for (int j = 0; j < i; ++j)
{
std::cin >> dane;
if (!(j == float(i) / 2))
{
plaszcz += 1 - 2 * (j > (i - 1) / 2);
}
if (plaszcz*(i - plaszcz + 1) <= number_of_bottles_needed)
{
if (min > dane)
{
min = dane;
}
}
}
}
std::cout << min;
return 0;
}
|