#include <iostream> #include <limits> int main() { int n, k; std::cin >> n >> k; int year[n][n]; for (int l = 0; l < n; ++l) { for (int r = 0; r < n; ++r) { year[l][r] = std::numeric_limits<int>::max(); } } for (int i = 0; i < n; ++i) { for (int r = 0; r < i; ++r) { int l = i - r - 1; std::cin >> year[l][r]; } } int best = std::numeric_limits<int>::max(); for (int l = 0; l < n && l + 1 <= k; ++l) { for (int r = 0; r < n && (l + 1) * (r + 1) <= k; ++r) { best = std::min(year[l][r], best); } } std::cout << best; }
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 | #include <iostream> #include <limits> int main() { int n, k; std::cin >> n >> k; int year[n][n]; for (int l = 0; l < n; ++l) { for (int r = 0; r < n; ++r) { year[l][r] = std::numeric_limits<int>::max(); } } for (int i = 0; i < n; ++i) { for (int r = 0; r < i; ++r) { int l = i - r - 1; std::cin >> year[l][r]; } } int best = std::numeric_limits<int>::max(); for (int l = 0; l < n && l + 1 <= k; ++l) { for (int r = 0; r < n && (l + 1) * (r + 1) <= k; ++r) { best = std::min(year[l][r], best); } } std::cout << best; } |