#include <cstdint> #include <iostream> int main() { int64_t n = 0; int64_t k = 0; std::cin >> n; std::cin >> k; int64_t min = 2020; for (int64_t i = 1; i < n + 1; ++i) { if (i > k) { break; } for (int64_t j = 1; j < i + 1; ++j) { int64_t year = 0; std::cin >> year; int64_t dist = j * (i + 1 - j); if (dist <= k) { min = std::min(min, year); } } } 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 25 26 27 28 29 30 31 32 | #include <cstdint> #include <iostream> int main() { int64_t n = 0; int64_t k = 0; std::cin >> n; std::cin >> k; int64_t min = 2020; for (int64_t i = 1; i < n + 1; ++i) { if (i > k) { break; } for (int64_t j = 1; j < i + 1; ++j) { int64_t year = 0; std::cin >> year; int64_t dist = j * (i + 1 - j); if (dist <= k) { min = std::min(min, year); } } } std::cout << min << std::endl; return 0; } |