#include <iostream> #include <vector> using LL = long long; int main() { std::ios_base::sync_with_stdio(false); int n,k,a; std::cin >> n >> k; std::vector<std::vector<int>> A(n); for (int i = 0; i < n; ++i) for (int j = 0; j <= i; ++j) { std::cin >> a; A[j].push_back(a); } int Min = A[0][0]; for (int j = 0; j < std::min(k, int(A.size())); ++j) { for (int i = 0; i < int(A[j].size()) && (1 + i)*(1 + j) <= k ; ++i) Min = std::min(Min, A[j][i]); } std::cout << Min << "\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 | #include <iostream> #include <vector> using LL = long long; int main() { std::ios_base::sync_with_stdio(false); int n,k,a; std::cin >> n >> k; std::vector<std::vector<int>> A(n); for (int i = 0; i < n; ++i) for (int j = 0; j <= i; ++j) { std::cin >> a; A[j].push_back(a); } int Min = A[0][0]; for (int j = 0; j < std::min(k, int(A.size())); ++j) { for (int i = 0; i < int(A[j].size()) && (1 + i)*(1 + j) <= k ; ++i) Min = std::min(Min, A[j][i]); } std::cout << Min << "\n"; return 0; } |