#include <iostream> #include <cstdio> using namespace std; int n, k, current; int minValue = 10000100; int main() { scanf ("%d%d", &n, &k); int x = 0; for (int y = 0; y < n; y++, x++) { for (int j = 0; j <= x; j++) { scanf ("%d", ¤t); int currResult = (j + 1) * (y - j + 1); if (currResult <= k && current < minValue) { minValue = current; } } } printf("%d", minValue); }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | #include <iostream> #include <cstdio> using namespace std; int n, k, current; int minValue = 10000100; int main() { scanf ("%d%d", &n, &k); int x = 0; for (int y = 0; y < n; y++, x++) { for (int j = 0; j <= x; j++) { scanf ("%d", ¤t); int currResult = (j + 1) * (y - j + 1); if (currResult <= k && current < minValue) { minValue = current; } } } printf("%d", minValue); } |