#include <cstdio> using namespace std; int main() { long result = 0; long n, k; long x; scanf("%ld %ld\n", &n, &k); for(int h=0; h<n; h++) { for (int i=0; i<=h; i++) { scanf("%ld", &x); long c = (i+1) * (h-i+1); //printf("%ld %ld %ld %ld\n", h, i, c, x); if (c <= k) { if (result == 0) { result = x; } else if(x < result) { result = x; } } } } printf("%ld\n", result); 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 | #include <cstdio> using namespace std; int main() { long result = 0; long n, k; long x; scanf("%ld %ld\n", &n, &k); for(int h=0; h<n; h++) { for (int i=0; i<=h; i++) { scanf("%ld", &x); long c = (i+1) * (h-i+1); //printf("%ld %ld %ld %ld\n", h, i, c, x); if (c <= k) { if (result == 0) { result = x; } else if(x < result) { result = x; } } } } printf("%ld\n", result); return 0; } |