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
34
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
    int n;
    cin>>n;
    int k;
    cin>>k;
    vector<vector<int>> piramid;
    int j = 1;
    for(int i = 0; i<n;i++){
        piramid.push_back({});
        for(int k = 0; k<j;k++){
            int z;
            cin>>z;
            piramid[i].push_back(z);
        }
        j++;
    }
    int accum = 0;
    int i = 0;
    for(;i<n && accum<k;i++){
        accum +=piramid[i].size();
    }
    i--;
    int res = piramid[0][0];
    for(int j = 0; j<=i;j++){
        for(int k = 0; k<piramid[j].size();k++){
            res=min(res,piramid[j][k]);
        }
    }
    cout<<res<<endl;
}