#include <bits/stdc++.h>
int main()
{
std::ios_base::sync_with_stdio(false);
std::cin.tie(NULL);
int n, k, m = 2020, i, j, y;
std::cin >> n >> k;
for (i = 1; i <= n; ++i) {
for (j = 1; j <= i; ++j) {
std::cin >> y;
if ((y < m) && ((i - j + 1) * j <= k))
m = y;
}
}
std::cout << m << "\n";
return 0;
}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | #include <bits/stdc++.h> int main() { std::ios_base::sync_with_stdio(false); std::cin.tie(NULL); int n, k, m = 2020, i, j, y; std::cin >> n >> k; for (i = 1; i <= n; ++i) { for (j = 1; j <= i; ++j) { std::cin >> y; if ((y < m) && ((i - j + 1) * j <= k)) m = y; } } std::cout << m << "\n"; return 0; } |
English