#include <cstdio> using namespace std; int n, k; inline bool reachable(int row, int col) { int needed = col * (row - col + 1); return needed <= k; } int main() { int curr; int min = 1000000; scanf("%d%d", &n, &k); for (int row = 1; row <= n; ++row) { for (int col = 1; col <= row; ++col) { scanf("%d", &curr); if (reachable(row, col) && curr < min) { min = curr; } } } printf("%d", min); 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 | #include <cstdio> using namespace std; int n, k; inline bool reachable(int row, int col) { int needed = col * (row - col + 1); return needed <= k; } int main() { int curr; int min = 1000000; scanf("%d%d", &n, &k); for (int row = 1; row <= n; ++row) { for (int col = 1; col <= row; ++col) { scanf("%d", &curr); if (reachable(row, col) && curr < min) { min = curr; } } } printf("%d", min); return 0; } |