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
35
36
37
38
#include <iostream>
#include <algorithm>
#include <vector>
 
int main()
{
    int x, y;
    std::cin >> x >> y;
 
    std::vector<std::vector<int>> pyramid(x);
 
    for(int i = 0; i < x; i++)
    {
        pyramid[i] = std::vector<int>(i + 1);
        for(int j = 0; j < i+1; j++)
        {
            std::cin >> pyramid[i][j];
        }
    }
 
    for(auto &s: pyramid)
    {
        if(s.size() < y)
        {
            y -= s.size();
            continue;
        }
        else
        {
            for(int i = 0; i < y - 1; i++)
            {
                s.erase(std::find(s.begin(), s.end(), *std::min_element(s.begin(), s.end())));
            }
            std::cout << *std::min_element(s.begin(), s.end()) << std::endl;
            break;
        }
    }
}