#include <iostream> int main() { int n, k; std::cin >> n >> k; int min; std::cin >> min; int currentYear; for(unsigned int i = 1; i < n; ++i) { for(unsigned int l = 1; l <= i+1; ++l) { std::cin >> currentYear; if(l * (i+1-l+1) <= k) if(currentYear < min) min = currentYear; } } std::cout << min << std::endl; 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 | #include <iostream> int main() { int n, k; std::cin >> n >> k; int min; std::cin >> min; int currentYear; for(unsigned int i = 1; i < n; ++i) { for(unsigned int l = 1; l <= i+1; ++l) { std::cin >> currentYear; if(l * (i+1-l+1) <= k) if(currentYear < min) min = currentYear; } } std::cout << min << std::endl; return 0; } |