// Author: Kamil Nizinski
// NOLINT(legal/copyright)
#ifdef LOCAL
#ifdef COLOR
#include "bits/cp_local_color.h"
#else
#include "bits/cp_local.h"
#endif
#else
#include "bits/stdc++.h"
#define debug_arr(arr_name, first, last)
#define debug(...)
#define cerr if (false) cerr
#define speed_of_cin_and_cout ios_base::sync_with_stdio(0), cin.tie(0)
#define local if (false)
#endif
#define ft first
#define sd second
#define psb push_back
#define sz(a) (static_cast<int>((a).size()))
using namespace std; // NOLINT(build/namespaces)
typedef int64_t LL;
typedef uint64_t LLU;
typedef long double LD;
typedef pair<int, int> PII;
const int kInf = 1000000007;
int solve() {
int n, k;
cin >> n >> k;
int answer = kInf;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= i; j++) {
int a;
cin >> a;
if (j * (i - j + 1) <= k)
answer = min(answer, a);
}
}
return answer;
}
int main() {
speed_of_cin_and_cout;
int test_cases_num = 1;
// cin >> test_cases_num;
for (int i = 1; i <= test_cases_num; i++) {
local if (test_cases_num > 1) cerr << "Test #" << i << ":\n";
cout << solve() << "\n";
local if (test_cases_num > 1) cerr << "End of test #" << i << ".\n";
}
return 0;
}
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 45 46 47 48 49 50 51 52 | // Author: Kamil Nizinski // NOLINT(legal/copyright) #ifdef LOCAL #ifdef COLOR #include "bits/cp_local_color.h" #else #include "bits/cp_local.h" #endif #else #include "bits/stdc++.h" #define debug_arr(arr_name, first, last) #define debug(...) #define cerr if (false) cerr #define speed_of_cin_and_cout ios_base::sync_with_stdio(0), cin.tie(0) #define local if (false) #endif #define ft first #define sd second #define psb push_back #define sz(a) (static_cast<int>((a).size())) using namespace std; // NOLINT(build/namespaces) typedef int64_t LL; typedef uint64_t LLU; typedef long double LD; typedef pair<int, int> PII; const int kInf = 1000000007; int solve() { int n, k; cin >> n >> k; int answer = kInf; for (int i = 1; i <= n; i++) { for (int j = 1; j <= i; j++) { int a; cin >> a; if (j * (i - j + 1) <= k) answer = min(answer, a); } } return answer; } int main() { speed_of_cin_and_cout; int test_cases_num = 1; // cin >> test_cases_num; for (int i = 1; i <= test_cases_num; i++) { local if (test_cases_num > 1) cerr << "Test #" << i << ":\n"; cout << solve() << "\n"; local if (test_cases_num > 1) cerr << "End of test #" << i << ".\n"; } return 0; } |
English