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
// 1st try.cpp : This file contains the 'main' function. Program execution begins and ends there.
//Mateusz Wasilewski

#include <bits/stdc++.h>
using namespace std;
int n, k, wynik=4000,a;
int tab[2010][2010];
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin >> n >> k;
	for (int i = 2; i <= n+1; i++) {
		for (int z = 1; z < i; z++) {
			cin >> a;
			tab[i][z] = tab[i - 1][z - 1] + tab[i - 1][z] - tab[i - 2][z - 1] + 1;
			if (tab[i][z] <= k) {
				wynik = min(wynik, a);
			}
		}
	}
	cout << wynik;
}

// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu