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
#include <iostream>                                                      
using namespace std;                                                            
                                                                                                                                                           
int main()                                                                      
{                 
    int n,k,wine,king_wine, moves_to_remove;
    king_wine = 2020;
                                        
    cin >> n >> k;

    for (int h = 1; h <= n; h++)
    {
        for (int i = 1; i <= h; i++)
        {
            int left_nodes = i - 1;
            int right_nodes = h - i;
            moves_to_remove = (h-left_nodes)*(h-right_nodes);

            cin >> wine;

            if(moves_to_remove <= k){
                king_wine = std::min(king_wine, wine);
            }
        }
    }      

    cout << king_wine;                                                           
                                                                                
    return 0;                                                                   
}