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
#include<bits/stdc++.h>
using namespace std;
int n,k,A,wine;
vector<vector<int> >tab;
vector<int>test;
int main()
{
    cin>>n>>k;
    tab.assign(n+4,test);
    wine=2023;
    for(int i=1;i<=n;i++)
    {
        tab[i].push_back(2023);
        for(int j=1;j<=i;j++)
        {
            cin>>A;
            if(j==1 || j==i)
            {
                tab[i].push_back(i);
            }
            else
            {
                tab[i].push_back(tab[i-1][j-1]+tab[i-1][j]+1-tab[i-2][j-1]);
            }
            if(tab[i][j]<=k)
            {
                wine=min(wine,A);
            }
        }
    }
    cout << wine << endl;
}