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
39
40
41
42
43
44
#include <bits/stdc++.h>

using u32 = uint32_t;
using u64 = uint64_t;
using i32 = int32_t;
using i64 = int64_t;

int main()
{
    std::ios_base::sync_with_stdio(0);

    u32 n, k;
    std::cin >> n >> k;
    u32 totalNumberCount = n * (n + 1) / 2;
    u32 result = 2019;

    for (u32 index = 1; index <= totalNumberCount; index++)
    {
        u32 tmp;
        std::cin >> tmp;

        u32 current_level;
        for (u32 i = 1; i <= n; i++)
        {
            if (i * (i + 1) / 2 >= index)
            {
                current_level = i;
                break;
            }
        }

        u32 currentPositionOnLevel = index - ((current_level - 1) * (current_level) / 2);
        u32 currentNodeValue = currentPositionOnLevel * (current_level + 1 - currentPositionOnLevel);

        if (k >= currentNodeValue)
        {
            result = std::min(result, tmp);
        }
    }

    std::cout << result << std::endl;

    return 0;
}