#include <iostream> const int maxn = 2001; int num_bottles[maxn][maxn]; int bottle_age[maxn][maxn]; int main() { int n, k; int min_age = 100000; std::cin >> n >> k; for (int i = 0 ; i < n ; i++) { for (int j = 0 ; j <= i ; j++) { int age; std::cin >> age; if ((i - j + 1) * (j + 1) < k && min_age > age) { min_age = age; } } } std::cout << min_age; return 0; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | #include <iostream> const int maxn = 2001; int num_bottles[maxn][maxn]; int bottle_age[maxn][maxn]; int main() { int n, k; int min_age = 100000; std::cin >> n >> k; for (int i = 0 ; i < n ; i++) { for (int j = 0 ; j <= i ; j++) { int age; std::cin >> age; if ((i - j + 1) * (j + 1) < k && min_age > age) { min_age = age; } } } std::cout << min_age; return 0; } |